我觉得我可能漏了一些显而易见的东西,但我找不到遍历DataGridRow集合的方法。我的DataGrid有一个项目数据源,它是我设置的类的集合。我正在尝试遍历行并突出显示符合特定条件的任何行,但我无论如何都看不到该怎么做。
我觉得我可能漏了一些显而易见的东西,但我找不到遍历DataGridRow集合的方法。我的DataGrid有一个项目数据源,它是我设置的类的集合。我正在尝试遍历行并突出显示符合特定条件的任何行,但我无论如何都看不到该怎么做。
public class StateToBackgroundColorConverter : IValueConverter
{
#region IValueConverter Members
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null) return Colors.White.ToString();
var state = (State) value;
return state.WebColor;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
#endregion
}
<UserControl.Resources>
<Converters:StateToBackgroundColorConverter x:Key="stateToBackgroundColorConverter"/>
</UserControl.Resources>
<toolkit:DataGrid.RowStyle>
<Style TargetType="{x:Type toolkit:DataGridRow}">
<Style.Setters>
<Setter Property="FontWeight" Value="Bold" />
<Setter Property="Foreground" Value="{Binding AgentState.SubState, Converter={StaticResource subStateToColorConverter}}" />
<Setter Property="Background" Value="{Binding AgentState.State, Converter={StaticResource stateToBackgroundColorConverter}}" />
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
</Style.Setters>
</Style>
</toolkit:DataGrid.RowStyle>