0

有谁知道为什么在将列表框的 ItemSoure 绑定到 CellectionViewSource 的 View 属性时会自动触发 SelectionChanged 事件?我该如何阻止它?谢谢。代码如下:

<ListBox ItemTemplate="{StaticResource ListboxDataTemplate}"  x:Name="AllListBox"  SelectedItem="      Binding Master.SelectedTask,Mode=TwoWay}"   ItemsSource="{Binding Master.ViewSource.View}" />

//Code-behind
CollectionViewSource   ViewSource = new CollectionViewSource();
            ViewSource.Source = Tasks;
            ViewSource.SortDescriptions.Add(new SortDescription("Model.t_state", ListSortDirection.Ascending));
            ViewSource.SortDescriptions.Add(new SortDescription("Model.t_createtime", ListSortDirection.Descending));
            ViewSource.SortDescriptions.Add(new SortDescription("Model.t_importance", ListSortDirection.Descending));
            ViewSource.SortDescriptions.Add(new SortDescription("Model.t_nam", ListSortDirection.Ascending));
4

1 回答 1

0

您是否在后面的代码中随时更改 SelectedItem 或 SelectedIndex?

于 2012-08-03T03:06:58.947 回答