tags:

views:

43

answers:

3

Hi

I want to gray out text in the WPF text block. how do i make it?

Regards Raju

A: 

Use TextBox instead and set IsReadOnly = true or IsEnabled = false

VoodooChild
+2  A: 

On C#:

textBox.Foreground = Brushes.Gray;

On XAML:

<TextBox Foreground="Gray" />

To disable it (will change background too):

textBox.IsEnabled = false;
Carlo
+1  A: 

You can set the TextBlock.Foreground property to any color (technically, any Brush). If you want it to be grayed out, just set:

<TextBlock Text="Foo" Foreground="Gray" />

If you want it to look "disabled", you can set IsEnabled to false:

<TextBlock Text="Foo" IsEnabled="false" />
Reed Copsey
I want to use IsEnabled flag. once i set it to false it doesn't have any effect. what could be the problem?
@user209293: How did you set it to false?
Reed Copsey
I did it in the code side. textblock.Isenabled = false.