WPF SelectedIndex和IsSelected不同步

时间:2014-01-30 15:25:12

标签: c# wpf triggers listboxitem

<ListBox  Grid.Column="1"
                     HorizontalAlignment="Stretch"  SelectedIndex="{Binding SelectedListIndex}"
                     VerticalAlignment="Stretch" BorderThickness="0" >       
        <ListBox.ItemContainerStyle>
            <Style TargetType="{x:Type ListBoxItem}">
                <Setter Property="Visibility" Value="Collapsed"/>
               <Style.Triggers>
                    <Trigger Property="IsSelected" Value="true">
                        <Setter Property="Visibility" Value="Visible"/>
                    </Trigger>
                </Style.Triggers>
            </Style>
        </ListBox.ItemContainerStyle>

这是我的xaml,“SelectedListIndex”是一个来自viewmodel的属性绑定,我更新了他。 我只想显示所选项目,可见性应随触发器更新。 当我删除触发器时,所选项目会更改。但是当我按下触发器时,可见性不会更新。

0 个答案:

没有答案
相关问题