0
这是我的第一个条目,请耐心等待我。 我的问题是,我有一个DataGrid内的扩展。扩展器用于分组。我也有一个过滤器文本框,它可以过滤视图并只显示匹配的行。 我的问题是:分组扩展器isexpanded属性在搜索时发现条目应为true,如果未使用搜索,则为false。 这是我DataGrid.GroupStyle:如何绑定动态创建的扩展器的isexpanded属性
<DataGrid.GroupStyle>
<GroupStyle ContainerStyle="{StaticResource GroupHeaderSettingsStyle}">
<GroupStyle.Panel>
<ItemsPanelTemplate>
<DataGridRowsPresenter/>
</ItemsPanelTemplate>
</GroupStyle.Panel>
</GroupStyle>
</DataGrid.GroupStyle>
这是静态资源
<Style x:Key="GroupHeaderSettingsStyle" TargetType="{x:Type GroupItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GroupItem}">
<Expander x:Name="Exp" IsExpanded="{Binding Path=FilterExpander,Mode=TwoWay}">
<Expander.Header>
<TextBlock Text="{Binding Name}" Foreground="White"/>
</Expander.Header>
<ItemsPresenter/>
</Expander>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
,这是我的C#属性:
public bool? FilterExpander
{
get
{
return _FilterExpander;
}
set
{
_FilterExpander = value;
RaisePropertyChanged(() => FilterExpander);
}
}
它从未进入 “获取法” ,所以我认为这个问题在xaml代码中。但我不确定。
我希望你能帮助我。 如果我忘记了一些代码片段或信息,请让我知道。
感谢
我曾尝试:
所有 “模式” 所有UpdateSourceTriggers, 同样的RelativeSource绑定
这可能是因为'FilterExpander'属性不是'GroupItem' DataContext的一部分。您可以尝试将其移入代表“DataGrid”的GroupItems的类中(它包含“Name”属性)。 – bars222
也许这可以帮助你http://stackoverflow.com/questions/6099141/expander-isexpanded-binding?rq=1 – bars222
感谢您的回复。 FilterExpander属性是在DataContext类中,并且链接也没有帮助:但是,无论如何,谢谢 – Evosoul