简体   繁体   English

是否有可能更改DataGridRowGroupHeader控件的内容?

[英]Is there a possibility to change content of DataGridRowGroupHeader control?

I'm using DataGrid control from WindowsCommunityToolkit and I want to fully localize this control. 我正在使用WindowsCommunityToolkit中的DataGrid控件,并且希望完全本地化此控件。

I found option to change grouping category name (RowGroupHeaderPropertyNameAlternative property), but I can't find any to change phrase that tell how many items is in the grouped category (string "x items" to other word) in the same view. 我找到了用于更改分组类别名称的选项(RowGroupHeaderPropertyNameAlternative属性),但是我找不到在同一视图中更改可告诉分组类别中多少个项目(字符串“ x个项目”改为其他字词)的短语。

Is there some control template or property to get custom text in DataGridRowGroupHeader? 是否有一些控件模板或属性可在DataGridRowGroupHeader中获取自定义文本?

but I can't find any to change phrase that tell how many items is in the grouped category (string "x items" to other word) in the same view. 但我找不到任何要更改的词组来告诉同一视图中分组类别中有多少个项目(字符串“ x个项目”改为其他词)。

The WindowsCommunityToolkit is open source. WindowsCommunityToolkit是开源的。 You actually could download it and check the DataGrid source code. 您实际上可以下载它并检查DataGrid源代码。 What you mentioned about 'string x items' is specified in its C# code. 您提到的有关“字符串x项”的内容在其C#代码中指定。 You could see this line . 您可以看到这条线

if (_itemCountElement != null && this.RowGroupInfo != null && this.RowGroupInfo.CollectionViewGroup != null)
{
        _itemCountElement.Text = string.Format(
                CultureInfo.CurrentCulture,
                this.RowGroupInfo.CollectionViewGroup.GroupItems.Count == 1 ? Properties.Resources.DataGridRowGroupHeader_ItemCountSingular : Properties.Resources.DataGridRowGroupHeader_ItemCountPlural,
                this.RowGroupInfo.CollectionViewGroup.GroupItems.Count);
 }

The string format template is defined in resource file: 字符串格式模板在资源文件中定义:

在此处输入图片说明

So, if you want to localize it by yourself, you could start from this point. 因此,如果您想自己进行本地化,则可以从这一点开始。 And compile a custom DataGrid version for your project. 并为您的项目编译自定义DataGrid版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM