如何在Xceed Datagrid中更改组级别指示器文本

时间:2019-01-10 15:40:28

标签: xceed-datagrid

我在WPF的Xceed DataGrid上有一个复杂的列(绑定到一个对象而不是一个属性),我必须实现自定义分组才能使其正确分组。它可以工作,但是当我按一列分组时,顶部的“组级别指示器”文本显示为“ Release.Value”而不是“ Release”。如何修改此文字?

XAML:

<Window.Resources>
    <models:ReleaseGroupDescription x:Key="releaseGroupDescription" PropertyName="Release.Value" />
</Window.Resources>

...

<xcdg:Column FieldName="Release" Title="RELEASE" Width="55" CellHorizontalContentAlignment="Center" GroupDescription="{StaticResource releaseGroupDescription}" CellVerticalContentAlignment="Center">
    <xcdg:Column.CellContentTemplate>
        <DataTemplate x:Name="releaseTemplate">
        <DockPanel HorizontalAlignment="Stretch" LastChildFill="True">
            <CheckBox IsChecked="{Binding Value}" IsEnabled="{Binding Enabled}" Click="Release_Click"></CheckBox>
        </DockPanel>
    </DataTemplate>
</xcdg:Column.CellContentTemplate>

CS:

public class ReleaseGroupDescription : DataGridGroupDescription
{
    public ReleaseGroupDescription()
        : base()
    {
    }
    public ReleaseGroupDescription(string propertyName)
        : base(propertyName)
    {
    }

    public override object GroupNameFromItem(object item, int level, 
    System.Globalization.CultureInfo culture)
    {
        object value = base.GroupNameFromItem(item, level, culture);
        try
        {
            string content = Convert.ToString(value);
            value = content;
        }
        catch (InvalidCastException)
        {
        }
        return value;
    }
}

0 个答案:

没有答案