Hitesh
Hitesh

Reputation: 1228

Silverlight converter in Datagrid

I have a radiobutton and textbox in datagird DataGridTemplateColumn.

If radiobutton is cheked,I want to change forecolor of textbox using converter.

I have bound a property to radiobuton and textbox and I want to change textbox color.

Following is my code:

  <TextBlock Text="{Binding Path=Firstname}"  Foreground="{Binding isTrue, Converter={StaticResource ChangeColor}}" Grid.Column="1" Width="80">

Thanks

Upvotes: 0

Views: 574

Answers (2)

Silver Light
Silver Light

Reputation: 50

You can use it in following way.

<UserControl.Resources>        
       <Converters:ChangeColor x:Key="ChangeColor"/>
</UserControl.Resources>

You have to put above code in your xaml file.

Upvotes: 1

Silver Light
Silver Light

Reputation: 50

You have to create a converter class and convert mehod.Use following code:

   SolidColorBrush result = new SolidColorBrush(Colors.Black);
        bool visible = System.Convert.ToBoolean(value);

        if (visible == true)
        {
            return result = new SolidColorBrush(Colors.Gray);
        }
        else
            return result;

and in Xaml file use like it:

  <TextBlock Text="{Binding Path=Firstname}"  Foreground="{Binding isTrue, Converter={StaticResource ChangeColor}}" Grid.Column="1" Width="80">

Upvotes: 2

Related Questions