Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

WPF binding not worked for foreground property in TextBlock

$
0
0

Hi All,

I want to set the text color of textblock text with foreground property

http://msdn.microsoft.com/en-us/library/system.windows.controls.textblock.foreground(v=vs.100).aspx

So I have following code to set the foreground property

TextBlock label = new TextBlock() { Style = LabelStyle }; Binding binding = new Binding(LabelColor) { Source = dataContextProperty }; label.SetBinding(TextBlock.ForegroundProperty, binding);

Note that LabelColor is a Brush. If I set,

label.SetBinding(TextBlock.BackgroundProperty, binding)

It worked for background. So why it is not working only for foreground?



Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>