WPF的Datagrid组扩展文本 - 如何绑定? [英] WPF Datagrid group expander text - how to bind?
问题描述
我使用与应改变分组字段一个COMBOX一个DataGrid。我使用下面的XAML来定义通用分组模板:
I am using a datagrid with a combox that should change the grouping field. I am using the following xaml to define the general grouping template :
<DataGrid.GroupStyle>
<GroupStyle>
<GroupStyle.ContainerStyle>
<Style TargetType="{x:Type GroupItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GroupItem}">
<Expander>
<Expander.Header>
<StackPanel Orientation="Horizontal">
<TextBlock Text="NEEDS TO BE BINDED..."/>
</StackPanel>
</Expander.Header>
<ItemsPresenter />
</Expander>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GroupStyle.ContainerStyle>
</GroupStyle>
</DataGrid.GroupStyle>
我只需要能够在膨胀机内'达到'该TextBlock中,以便能够输出施加所选择的分组
I only need to be able to 'reach' that TextBlock within the expander to be able to output the selected grouping applied.
请帮忙....
推荐答案
我已经通过添加包含当前选定的分组(我手动设置ofcourse)+更多的细节,我需要一个嵌套类解决了我的问题。然后,通过使用绑定到类属性:
I have solved my issue by adding a nested class that contains the currently selected grouping (which i manually set ofcourse) + more details i need. Then binding to the class property by using :
&LT; TextBlock的文本={绑定源= {StaticResource的GroupingSubject},路径=名称}/&GT;
Ofcourse,我不得不在XAML资源范围内声明类如下:
Ofcourse that i had to declare the class within the xaml resources as follows :
&lt;局部:GroupingName X:键=GroupingName/&GT;
我的嵌套类看起来如下:
My nested class looks as follows :
public class GroupingSubject
{
private static String name = null;
private static Object groupType = null;
public GroupingSubject() { }
public static String Name
{
get { return name; }
set { name = value; }
}
public static Object GroupType
{
get { return groupType; }
set { groupType = value; }
}
}
现在一切都很好...
Now all is well...
这篇关于WPF的Datagrid组扩展文本 - 如何绑定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!