0

所以在 Xceed 文档中有一个对我不起作用的代码示例。可能是因为我的网格绑定到 DataGridCollectionView。datagridcollection 使用的集合中的对象实现了 IDataErrorInfo。

错误显示得很好。问题是他们使用默认的橙色背景来显示错误......我需要一个红色边框。下面是我的网格的 XAML 实例化。我将 DataCell 背景属性设置为红色,这样我可以确定我可以访问网格的属性……我可以。我只是找不到识别单元格错误的方法,所以我可以设置它们的样式。谢谢!

        <XceedDG:DataGridControl Grid.Row="1" Grid.ColumnSpan="5" ItemsSource="{Binding Path = ABGDataGridCollectionView, UpdateSourceTrigger=PropertyChanged}"
                                     Background="{x:Static Views:DataGridControlBackgroundBrushes.ElementalBlue}" IsDeleteCommandEnabled="True"
                                     FontSize="16" AutoCreateColumns="False" x:Name="EncounterDataGrid" AllowDrop="True">

        <XceedDG:DataGridControl.View>
            <Views:TableView ColumnStretchMode="All" ShowRowSelectorPane="True" 
                     ColumnStretchMinWidth="100">
                <Views:TableView.FixedHeaders>
                    <DataTemplate>
                        <XceedDG:InsertionRow Height="40"/>
                    </DataTemplate>
                </Views:TableView.FixedHeaders>
            </Views:TableView>

        </XceedDG:DataGridControl.View>
        <!--Group Header formatting-->
        <XceedDG:DataGridControl.Resources>
            <Style TargetType="{x:Type XceedDG:GroupByControl}">
                <Setter Property="Visibility" Value="Collapsed"/>
            </Style>
            <Style TargetType="{x:Type XceedDG:DataCell}">
                <Setter Property="Background" Value="Red"/>
            </Style>
        </XceedDG:DataGridControl.Resources>

...

4

1 回答 1

1

知识库入口:

http://xceed.com/KB/questions.php?questionid=256

似乎确实可能缺少关键部分。

您是否尝试过 DataGridView 上的CellErrorStyle 属性

<Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid">
  <Grid.Resources>
    <Style x:Key="errorStyle" TargetType="{x:Type xcdg:DataCell}">
      <Setter Property="Foreground" Value="Red"/>
    </Style>
  </Grid.Resources>

  <xcdg:DataGridControl CellErrorStyle="{StaticResource errorStyle}" >
       <!--STUFF OMITTED-->
  </xcdg:DataGridControl>
</xcdg:DataGridControl>

于 2010-05-18T01:23:12.397 回答