【发布时间】:2013-04-25 03:59:40
【问题描述】:
有没有办法修复Selection Change Event的已知错误,如果再次点击相同的项目,则选择不起作用。
为了提供更多背景信息,我的场景是我的数据透视页面中有四个项目,当我单击其中一个项目时,我将被导航到另一个页面。现在我的困境是,当我再次选择相同的项目时,导航不起作用或什么也没有发生。
请让我知道您建议的修复方法,非常感谢。
<ListBox x:Name="lbviewlist" ItemsSource="{Binding items}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="selectionchanged">
<Command:EventToCommand Command ="{Binding ItemListCommand }" PassEventArgsToCommand="True" />
</i:EventTrigger>
</i:Interaction.Triggers>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock TextWrapping="Wrap" Text="{Binding itemName}" FontSize="30" Margin="10,0,0,0" Style="{StaticResource PhoneTextTitle2Style}" Foreground="CadetBlue"/>
<TextBlock TextWrapping="Wrap" Text="{Binding itemDescription}" FontSize="20" Margin="15,5,0,10"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
【问题讨论】:
-
这不是一个错误,
SelectedChanged完全按照它应该做的事情,它在选择更改时触发,如果选择了相同的元素,它没有改变所以它不会触发。您可能必须使用 Item 上的 MouseEvents 或 ListBox 本身来处理此问题 -
@sa_ddam213 请教我怎么做?我只是这个领域的新手,不知何故很难理解这个概念。您的意思是我应该将选择更改事件更改为鼠标事件吗?顺便说一下,我正在使用 MVVM
标签: wpf events selecteditem selectionchanged