0

我正在尝试为 Windows 8 Metro App 中的 devexpress xaml 网格的奇数行和偶数行添加备用行颜色。我怎样才能做到这一点?我在谷歌上搜索了很多,但在我的大多数示例中,我的命名空间引用不匹配。我正在使用 Devexpress v12.2。

4

2 回答 2

0

因此?:

<MultiDataTrigger>
    <MultiDataTrigger.Conditions>
        <Condition Binding="{Binding Path=EvenRow}" Value="False"/>
        <Condition Binding="{Binding Path=SelectionState}" Value="None"/>
    </MultiDataTrigger.Conditions> 
    <Setter Property="Background" Value="{StaticResource evenRowBrush}" />
</MultiDataTrigger>

<MultiDataTrigger>
    <MultiDataTrigger.Conditions>
        <Condition Binding="{Binding Path=EvenRow}" Value="True"/>
        <Condition Binding="{Binding Path=SelectionState}" Value="None"/>
    </MultiDataTrigger.Conditions>
    <Setter Property="Background" Value="{StaticResource oddRowBrush}" />
</MultiDataTrigger>
于 2013-02-20T13:31:33.997 回答
0

您可以修改GridControl.ItemTemplate(行模板)。这种方法在条件格式演示模块(DevExpress v12.2 功能演示)中进行了演示:

<UserControl 
    ...
    xmlns:Grid="using:DevExpress.UI.Xaml.Grid">
    <UserControl.Resources>
        <local:RowHandleToBackgroundConverter x:Key="RowHandleToBackgroundConverter" EvenRowBackground="Transparent" OddRowBackground="#FFDFE7EF"/>
    </UserControl.Resources>
...
<Grid:GridControl.ItemTemplate>
    <DataTemplate>
        <Border Background="{Binding Path=RowControl.RowHandle, RelativeSource={RelativeSource Mode=TemplatedParent}, Converter={StaticResource RowHandleToBackgroundConverter}}">
            <Grid:GridCellPanel x:Name="PART_RowPanel" RowControl="{Binding Path=RowControl, RelativeSource={RelativeSource Mode=TemplatedParent}}" Margin="0,0,1,0"/>
        </Border>
    </DataTemplate>
</Grid:GridControl.ItemTemplate>

'RowHandleToBackgroundConverter' 类实现如下:

public class RowHandleToBackgroundConverter : IValueConverter {
    public Brush EvenRowBackground { get; set; }
    public Brush OddRowBackground { get; set; }
    public object Convert(object value, Type targetType, object parameter, string language) {
        if(((int)value % 2) == 0)
            return OddRowBackground;
        else
            return EvenRowBackground;
    }
    public object ConvertBack(object value, Type targetType, object parameter, string language) {
        throw new NotImplementedException();
    }
}
于 2013-02-20T14:33:42.790 回答