更新2:通过Xceed文档和Xceed论坛我发现,你必须设置RowSelectorStyle每个DataRow的浏览。
<Grid.Resources>
<Style x:Key="mySelectorStyle" TargetType="{x:Type xcdg:RowSelector}">
<Setter Property="Background" Value="LightGreen"/>
<Setter Property="BorderBrush" Value="DarkGreen"/>
</Style>
<Style TargetType="{x:Type xcdg:DataRow}">
<Setter Property="xcdg:RowSelector.RowSelectorStyle"
Value="{StaticResource mySelectorStyle}" />
</Style>
</Grid.Resources>
更新3 你是对的,我错过了行部分外的部分:rowselectorpane本身。不幸的是,这是不可风格的。 有2个选项:
重写TableViewScrollViewer的ControlTemplate的Xceed论坛的建议。但这是xaml的大部分工作的繁琐复制粘贴工作,并且改变了您希望以自己的方式使用它的小部分。
或者以下的小黑客:
private void dataGridLoaded(object sender, RoutedEventArgs e)
{
var rowSelectorPane = TreeHelper.FindVisualChild<RowSelectorPane>(_dataGrid);
if (rowSelectorPane != null)
{
rowSelectorPane.Background = Brushes.LightGreen;
}
}
public static class TreeHelper
{
public static TChildItem FindVisualChild<TChildItem>(DependencyObject obj) where TChildItem : DependencyObject
{
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
{
DependencyObject child = VisualTreeHelper.GetChild(obj, i);
if (child != null && child is TChildItem)
return (TChildItem)child;
TChildItem childOfChild = FindVisualChild<TChildItem>(child);
if (childOfChild != null)
return childOfChild;
}
return null;
}
}
的XAML: <xcdg:DataGridControl ItemsSource="{Binding}" Name="_dataGrid" Loaded="dataGridLoaded" etc...>
这似乎在RowSelectorPane一半工作,因为它的数据行只颜色。那么在ColumnManagerCells的区域周围或数据尚未设置的区域呢?当然,我非常感谢你的帮助,如果这些不能修改,那么这将不得不做 – Seb
看起来我有很多工作在我面前。非常感谢你的帮助。 – Seb