Windows phone 7 为什么在将listbox的ItemSoure绑定到CellViewSource的View属性时会自动触发SelectionChanged事件?

Windows phone 7 为什么在将listbox的ItemSoure绑定到CellViewSource的View属性时会自动触发SelectionChanged事件?,windows-phone-7,Windows Phone 7,有人知道为什么在将listbox的ItemSoure绑定到CellSectionViewSource的View属性时会自动触发SelectionChanged事件吗?如何停止此操作?谢谢。代码如下: <ListBox ItemTemplate="{StaticResource ListboxDataTemplate}" x:Name="AllListBox" SelectedItem=" Binding Master.SelectedTask,Mode=TwoWay}"

有人知道为什么在将listbox的ItemSoure绑定到CellSectionViewSource的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));

//代码隐藏
CollectionViewSource ViewSource=新的CollectionViewSource();
ViewSource.Source=任务;
添加(新的sortddescription(“Model.t_state”,ListSortDirection.升序));
添加(新的SortDescription(“Model.t_createtime”,ListSortDirection.Descending));
添加(新的SortDescription(“Model.t_重要性”,ListSortDirection.Descending));
添加(新的sortddescription(“Model.t_nam”,ListSortDirection.升序));

是否在代码隐藏的任何时间点更改SelectedItem或SelectedIndex?

是的,当页面开始导航到时,这两个属性都会在OnNavigatedTo方法中初始化。this.AllListBox.SelectedIndex=-1;SelectedTask=null。如果我不使用CollectionViewSource对此列表框的项目进行排序,则在加载页面后不会触发该列表框。当您更改这些值时,将触发selection changed事件。您可以使用断点来验证这一点。我建议不要在OnNavigatedTo方法中初始化它们。