I have a problem with my expander. (again...)
I have a DataGrid with an unknown number of entry's. Each Entry is different and added manually. Each of them has a specific "Area" they belongs to. The entry's are grouped through the "Area". The Grouping is carried out with a GroupItem. Within this GroupItem there is an Expander, with an IsExpanded Binding. I also have a filter TextBox where the entry's are filtered and only the correct one's are shown in the Groups. If the filter finds an entry, than the isExpanded Property of all Expanders should be true. If the filter doesn't find an entry, than the isexpanded is false. The problem in this solution is: If I click on one Expander, all Expanders isExpanded Property is set to true, but it should only be the one I clicked.
I know this bevahiour is because I only have 1 Expander which is created multiple times.
Now to the question: Is it possible that only the expander I click is opened and if the Filter finds a value, all expanders are opened?
This is the Property:
public bool? FilterExpander
{
get
{
return _FilterExpander;
}
set
{
_FilterExpander = value;
RaisePropertyChanged(() => FilterExpander);
}
}
This is the Headerstyle where the Expander is:
<Style x:Key="GroupHeaderSettingsStyle" TargetType="{x:Type GroupItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GroupItem}">
<Expander x:Name="Exp" IsExpanded="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl},Mode=FindAncestor},Path=DataContext.FilterExpander}" >
<Expander.Header>
<TextBlock Text="{Binding Name}" Foreground="White"/>
</Expander.Header>
<ItemsPresenter/>
</Expander>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
I hope this is possible and someone can help me.
Thanks in advance