this is my first entry, so please be patient with me. My problem is that i have Expanders inside a DataGrid. The Expanders are used for Grouping. I also have a filter textfield which filters the View and shows only the matching lines. My problem is: the Grouping expanders isexpanded property should be true when the search finds entries and false if the search is not used. This is my DataGrid.GroupStyle:
<DataGrid.GroupStyle>
<GroupStyle ContainerStyle="{StaticResource GroupHeaderSettingsStyle}">
<GroupStyle.Panel>
<ItemsPanelTemplate>
<DataGridRowsPresenter/>
</ItemsPanelTemplate>
</GroupStyle.Panel>
</GroupStyle>
</DataGrid.GroupStyle>
This is the StaticResource
<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>
And this is my C# Property:
public bool? FilterExpander
{
get
{
return _FilterExpander;
}
set
{
_FilterExpander = value;
RaisePropertyChanged(() => FilterExpander);
}
}
It never gets into the "get-method", so I think the problem is within the xaml Code. But I am not sure.
I hope you can help me. If I forgot some Code Snippets or information please let me know.
Thanks
What I have tried:
All "modes" All UpdateSourceTriggers, Also RelativeSource Binding
FilterExpander
property is not the part of theGroupItem
DataContext. You can try to move it into class that represents GroupItems ofDataGrid
(that containsName
property). – bars222