1
我正在重温一个我曾经工作过的MVVM Windows Phone项目,当我将一个Trigger添加到ListBox时遇到问题。我已将项目升级到7.1。我以前有代码如下: -设置针对ListBox的触发器时引发的异常
<ListBox x:Name="MainListBox"
ItemsSource="{Binding MyItems}"
Grid.Row="1"
Margin="12"
ItemContainerStyle="{StaticResource MyListItemStyle1}"
SelectedIndex="{Binding CurrentSelectedIndex, Mode=TwoWay}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
i:Interaction.Triggers="{StaticResource PerformSelectionChangedEventTrigger}" />
不过我现在收到的异常,如下所示: -
无法设置只读属性“System.Windows.Interactivity.Interaction.Triggers
进行以下更改似乎解决这个问题: - 我已经寻找异常消息
<ListBox x:Name="MainListBox"
ItemsSource="{Binding MyListItems}"
Grid.Row="1"
Margin="12"
ItemContainerStyle="{StaticResource MyListItemStyle1}"
SelectedIndex="{Binding CurrentSelectedIndex, Mode=TwoWay}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<cmdextras:EventToCommand Command="{Binding Path=PerformSelectionChanged}"
PassEventArgsToCommand="True" />
</i:EventTrigger>
</i:Interaction.Triggers>
</ListBox>
但是我不确定为什么“内联”触发设置使用为w ork不再有效。
有人能够对此有所了解吗?