【问题标题】:How do I change the CellErrorStyle for an Xceed Datagrid?如何更改 Xceed Datagrid 的 CellErrorStyle?
【发布时间】:2010-05-17 20:59:09
【问题描述】:

所以在 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>

...

【问题讨论】:

    标签: wpf errorprovider xceed-datagrid


    【解决方案1】:

    知识库入口:

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

    似乎确实缺少关键部分。

    您是否尝试过 DataGridView 上的 CellErrorStyle Property

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

    【讨论】:

    • 你成功了。是的,文档中有明显的遗漏,这使得他们在风格上使用的关键字(cell_error)看起来像是某种保留字。非常令人沮丧。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-02-09
    • 1970-01-01
    • 2016-07-10
    • 2016-02-25
    • 1970-01-01
    • 2018-07-15
    • 1970-01-01
    相关资源
    最近更新 更多