【问题标题】:How can I change the BackgroundColor of current row?如何更改当前行的背景颜色?
【发布时间】:2012-06-12 13:51:06
【问题描述】:

我正在评估 DeveloperExpress WPF 控件。 DevExpressGridControl当前行的BackgroundColor如何更改?

【问题讨论】:

  • 目前尚不清楚您正在尝试哪种控制方式以及您面临的问题。

标签: .net wpf datagrid devexpress background-color


【解决方案1】:

也许this之前的帖子会对你有所帮助。

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

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

希望能有所帮助。

【讨论】:

  • 感谢您的回答,我看过那篇文章,但不幸的是,这不是解决方案。我也尝试过文档,但它不完整。
【解决方案2】:

我同意 Marc 的观点,一般来说,为 3'rd 方控件找到解决方案的最佳位置是他们的文档和论坛;这是来自 devexpress 论坛帖子的代码 sn-p -

<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"

【讨论】:

    猜你喜欢
    • 2020-04-17
    • 1970-01-01
    • 2021-12-30
    • 2017-05-31
    • 1970-01-01
    • 2014-08-04
    • 2011-11-11
    • 1970-01-01
    • 2016-03-15
    相关资源
    最近更新 更多