答案 0 :(得分:3)
您的问题是由Group的DataTemplate
中硬编码的“项目”标签引起的。
因此解决方案是覆盖DataTemplate
。使用implicit data templating并不困难:只需将DataTemplate
放在窗口的资源DataGridControl
:
<Window x:Class="Sample.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:toolkit="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid"
Title="MainWindow" Height="400" Width="400">
<Window.Resources>
<xcdg:StringFormatMultiConverter x:Key="stringFormatMultiConverter" />
<DataTemplate x:Key="customGroupTemplate">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<ContentPresenter VerticalAlignment="Center" Content="{Binding Title}" ContentTemplate="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=DataContext.TitleTemplate}" ContentTemplateSelector="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=DataContext.TitleTemplateSelector}" />
<TextBlock Text=": " VerticalAlignment="Center" />
<ContentPresenter VerticalAlignment="Center" ContentTemplate="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=DataContext.ValueTemplate}" ContentTemplateSelector="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=DataContext.ValueTemplateSelector}">
<ContentPresenter.Content>
<MultiBinding Converter="{StaticResource stringFormatMultiConverter}">
<Binding Path="Value" />
<Binding Path="DataContext.ValueStringFormat" RelativeSource="{RelativeSource TemplatedParent}" />
<Binding Path="DataContext.ValueStringFormatCulture" RelativeSource="{RelativeSource TemplatedParent}" />
</MultiBinding>
</ContentPresenter.Content>
</ContentPresenter>
<TextBlock Text=" (" VerticalAlignment="Center" />
<TextBlock VerticalAlignment="Center" Text="{Binding ItemCount}" />
<TextBlock Text=" " VerticalAlignment="Center" />
<TextBlock Name="suffixRun" Text="položky" VerticalAlignment="Center" />
<TextBlock Text=")" VerticalAlignment="Center" />
</StackPanel>
<DataTemplate.Triggers>
<DataTrigger Value="1" Binding="{Binding ItemCount}">
<Setter TargetName="suffixRun" Property="TextBlock.Text" Value="položka" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
<DataTemplate DataType="{x:Type xcdg:Group}">
<ContentControl Name="groupContentPresenter" Focusable="False"
ContentTemplate="{StaticResource customGroupTemplate}" Content="{Binding}" />
</DataTemplate>
</Window.Resources>
我用ILSpy嗅探了默认模板,然后我创建了自己的模板,翻译了“items”一词。
我希望它可以帮到你。