为什么在将Listbox的ItemSoure绑定到CellectionViewSource的View属性时自动触发SelectionChanged事件?

时间:2012-08-02 13:59:25

标签: windows-phone-7

有没有人知道为什么在将Listbox的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));

1 个答案:

答案 0 :(得分:0)

您是否在代码后面的任何时间点更改SelectedItem或SelectedIndex?