如何更改当前行的背景颜色?

时间:2012-06-08 13:37:17

标签: .net wpf datagrid devexpress background-color

我正在评估DeveloperExpress WPF控件。如何更改当前行DevExpress BackgroundColor的{​​{1}}?

2 个答案:

答案 0 :(得分:1)

我同意Marc的观点,一般来说,找到第三方控制解决方案的最佳位置是他们的文档和论坛;这是来自devexpress论坛帖子的代码片段 -

<Window x:Class="DXGrid_ChangeRowAppearance.Window1" 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid" 
        Title="Window1" Height="300" Width="505">
    <Window.Resources>
        <Style x:Key="SelectedRowStyle" TargetType="{x:Type dxg:GridRowContent}">
            <Style.Triggers>
                <DataTrigger Binding="{Binding Path=IsSelected}" Value="True">
                    <Setter Property="Background" Value="Gray" />
                    <Setter Property="Foreground" Value="White" />
                </DataTrigger>
                <Trigger Property="dxg:GridViewBase.IsFocusedRow" Value="True">
                    <Setter Property="Background" Value="Red" />
                    <Setter Property="Foreground" Value="White" />
                </Trigger>
            </Style.Triggers>
        </Style>
    </Window.Resources>
    <Grid>
        <dxg:GridControl x:Name="grid" AutoPopulateColumns="True">
            <dxg:GridControl.View>
                <dxg:TableView AutoWidth="True" MultiSelectMode="Row" 
                     ShowGroupPanel="False" 
                     AllowGrouping="False" 
                     RowStyle="{StaticResource SelectedRowStyle}">
                </dxg:TableView>
            </dxg:GridControl.View>
        </dxg:GridControl>
    </Grid>
</Window>

http://www.devexpress.com/Support/Center/p/E2066.aspx

我认为这里的关键是在触发器中使用Property="dxg:GridViewBase.IsFocusedRow"

答案 1 :(得分:0)

也许this上一篇文章会对您有帮助。

此外,我强烈建议您查看devexpress在线文档here

您还可以在DevExpress网站上搜索官方论坛。有很多人面临同样的问题。

希望有所帮助。

相关问题