XAML: развернуть расширитель, когда выбран элемент в группе - PullRequest
0 голосов
/ 20 сентября 2019

Может ли экспандер проверить свойство IsExpanded, если выбран элемент внутри группы экспандера, тогда этот экспандер разворачивается, так что IsExpanded будет истинным?Потому что, если я установлю его в значение по умолчанию, все расширители будут расширены, это не является целью.

<controls:CommandListBox Grid.IsSharedSizeScope="True"
                                     Visibility="{Binding IsComponentOrSystemPropertySearch, Converter={StaticResource BooleanToVisibilityConverter}}"
                                     Grid.Column="2"
                                     HorizontalAlignment="Stretch"
                                     SelectedItem="{Binding SelectedResult}"
                                     ToolbarItems="{Binding ToolBarItems}"
                                     ItemsSource="{Binding SearchResults, UpdateSourceTrigger=PropertyChanged}">
                <ItemsControl.Resources>
                    <ResourceDictionary>
                        <Style x:Key="GroupHeaderStyle"
                               TargetType="{x:Type GroupItem}">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="{x:Type GroupItem}">
                    <Expander x:Name="exp"  IsExpanded="False" Margin="0,0,0,30" >
                                                <Expander.Header >
                                                    <TextBlock Text="{Binding Path=Name}" FontSize="18" Padding="0" Margin="0"/>
                                            </Expander.Header>
                                                    <Grid Margin="20 0 0 0" >
                                                        <Grid.ColumnDefinitions>
                                                            <ColumnDefinition Width="*"/>
                                                        </Grid.ColumnDefinitions>
                                                        <Grid.RowDefinitions>
                                                            <RowDefinition Height="*"/>
                                                            <RowDefinition Height="*"/>
                                                        </Grid.RowDefinitions>
                                                        <ContentPresenter Grid.Column="0"
                                                                          Grid.Row="0"
                                                            Content="{Binding Path=Items[0].DisplayRepresentation.Header}"/>
                                                        <ItemsPresenter Grid.Column="0"
                                                                        Grid.Row="1"/>
                                                    </Grid>
                                        </Expander>

                  </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </ResourceDictionary>
                </ItemsControl.Resources>
                <ItemsControl.GroupStyle>

                    <GroupStyle ContainerStyle="{StaticResource GroupHeaderStyle}">
                        <GroupStyle.Panel>
                            <ItemsPanelTemplate>
                                <DataGridRowsPresenter />
                            </ItemsPanelTemplate>
                        </GroupStyle.Panel>
                    </GroupStyle>
                </ItemsControl.GroupStyle>
                <ItemsControl.ItemTemplate>
                    <DataTemplate DataType="{x:Type local:DeluxePropertySearchResult}">
                        <ContentPresenter Content="{Binding DisplayRepresentation}" />
                    </DataTemplate>
        </ItemsControl.ItemTemplate>
      </controls:CommandListBox>
...