【发布时间】:2012-06-12 13:51:06
【问题描述】:
我正在评估 DeveloperExpress WPF 控件。 DevExpressGridControl当前行的BackgroundColor如何更改?
【问题讨论】:
-
目前尚不清楚您正在尝试哪种控制方式以及您面临的问题。
标签: .net wpf datagrid devexpress background-color
我正在评估 DeveloperExpress WPF 控件。 DevExpressGridControl当前行的BackgroundColor如何更改?
【问题讨论】:
标签: .net wpf datagrid devexpress background-color
我同意 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"。
【讨论】: