刷新ListView时,展开器关闭

时间:2016-09-01 13:14:53

标签: c# wpf listview expander

我有ListView启用了分组,ListView.GroupStyle上有自定义样式:GroupStyleExpander

 <ListView.GroupStyle>
    <GroupStyle>
        <GroupStyle.ContainerStyle>
            <Style TargetType="{x:Type GroupItem}">
               <Setter Property="Template">
               <Setter.Value>
               <ControlTemplate TargetType="{x:Type GroupItem}">
                      <Expander Style="{DynamicResource SettingsExpander}">
                           <Expander.Header>
                                 <TextBlock Style="{DynamicResource BigWhiteText}"
                                                       Text="{Binding Name}" />
                           </Expander.Header>
                        <Expander.Content>
                       <ItemsPresenter />
                      </Expander.Content>
                    </Expander>
                  </ControlTemplate>
               </Setter.Value>
             </Setter>
           </Style>
         </GroupStyle.ContainerStyle>
      </GroupStyle>
   </ListView.GroupStyle>

其中一个包含checkbox:如果选中,则启用以下元素,否则不启用。

Image of the group

我遇到的问题是当Checked值更改并刷新视图时,扩展器会崩溃。我该怎么办才能保持开放状态?

谢谢!

修改

My Expander风格如下:

<Style x:Key="SettingsExpander" TargetType="Expander" BasedOn="{StaticResource {x:Type Expander}}">
    <Setter Property="HorizontalAlignment" Value="Stretch" />
    <Setter Property="BorderBrush" Value="{DynamicResource StandardBorderColor}" />
    <Setter Property="Foreground" Value="{DynamicResource StandardBackgroundColor}" />
    <Setter Property="Margin" Value="5" />
</Style>

0 个答案:

没有答案