Wednesday, March 17, 2010

Pass DataContext to Silverlight IValueConverter

When passing DataContext to a Silverlight IValueConverter the following method is not supported:

<TextBox Text="{Binding Detail,
Mode
=TwoWay, NotifyOnValidationError=True,  ValidatesOnExceptions=True}" 
IsEnabled={Binding ,Converter="{StaticResource contactDetailsColorConverter}} >
</TextBox>

Instead you need to translate the the above out to its expanded tag version


<TextBox Text="{Binding Detail, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnExceptions=True}"  >
<TextBox.IsEnabled>
<Binding Converter="{StaticResource contactDetailsColorConverter}"/>
</TextBox.IsEnabled>
</TextBox>

No comments:

Post a Comment