请问为什么这样子绑定信息,没有文字的颜色没有发生变化
<DataGridTemplateColumn MinWidth="80" Header="最新价">
<DataGridTemplateColumn.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="Background" Value="Yellow"/>
<Setter Property="Foreground" >
<Setter.Value>
<MultiBinding Converter="{StaticResource LatestPriceFrocegroundConverter}">
<Binding Path="LatestPrice"/>
<Binding Path="EarlyMorning"/>
</MultiBinding>
</Setter.Value>
</Setter>
</Style>
</DataGridTemplateColumn.CellStyle>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding LatestPrice}" >
<!--<TextBlock.Foreground>
<MultiBinding Converter="{StaticResource LatestPriceFrocegroundConverter}">
<Binding Path="LatestPrice"/>
<Binding Path="EarlyMorning"/>
</MultiBinding>
</TextBlock.Foreground>-->
</TextBlock>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
/// <summary>
/// 最新价文字颜色转换器
/// 当最新价大于开盘价时为红色
/// 当最新价小于开盘价时为绿色
/// 当最新价等于开盘价时为白色
/// </summary>
class LatestPriceFrocegroundConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
if (values[0] == null || values[1] == null)
{
return null;
}
double temp = 0;
double d1 = 0;
double d2 = 0;
if (double.TryParse(values[0].ToString(), out temp))
{
d1 = temp;
}
else
{
return null;
}
if (double.TryParse(values[1].ToString(), out temp))
{
d2 = temp;
}
else
{
return null;
}
if (d1 > d2)
{
return Color.Red;
}
else if (d1 < d2)
{
return Color.Green;
}
else
{
return Color.White;
}
//return "Gold";
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}