converter fix
This commit is contained in:
@@ -15,10 +15,10 @@ namespace BindingValidationRuleSample.Converter
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (targetType != typeof(Brush))
|
||||
return null;
|
||||
return Brushes.Black;
|
||||
|
||||
if (value == null)
|
||||
return null;
|
||||
return Brushes.Black;
|
||||
|
||||
int age = int.Parse(value.ToString());
|
||||
return ValueColor(age);
|
||||
|
@@ -38,7 +38,8 @@
|
||||
<TextBox Grid.Column="1" Grid.Row="0" Margin="5"
|
||||
Text="{Binding Name, Mode=TwoWay}"/>
|
||||
<TextBox x:Name="tbxAge" Grid.Column="1" Grid.Row="1" Margin="5"
|
||||
ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}">
|
||||
ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}"
|
||||
Foreground="{Binding Path=Age, Mode=TwoWay, Converter={StaticResource cvtAgeToBrush}}">
|
||||
<TextBox.Text>
|
||||
<Binding Path="Age"
|
||||
Mode="TwoWay"
|
||||
@@ -49,8 +50,7 @@
|
||||
</Binding>
|
||||
</TextBox.Text>
|
||||
</TextBox>
|
||||
<TextBox Grid.Column="1" Grid.Row="2" Margin="5"
|
||||
Foreground="{Binding Path=Age, Mode=TwoWay, Converter={StaticResource cvtAgeToBrush}}"
|
||||
<TextBox Grid.Column="1" Grid.Row="2" Margin="5" Foreground="Blue"
|
||||
Text="{Binding PhoneNumber, Mode=TwoWay}"/>
|
||||
|
||||
<Grid Grid.Column="0" Grid.Row="4" Grid.ColumnSpan="2" Height="30">
|
||||
|
Reference in New Issue
Block a user