【问题标题】:Silverlight DataGrid makes the first selection when ItemsSource is Set, how can turn this off?Silverlight DataGrid 在设置 ItemsSource 时进行第一次选择,如何将其关闭?
【发布时间】:2010-08-26 21:29:53
【问题描述】:

我将 Silverlight 4 DataGrid 与 DataPager 一起使用。

当 DataGrid 的 ItemsSource 被设置时,它会选择列表中的第一行。

PagedCollectionView _list = new PagedCollectionView(myDataCollection);
_dataPager.Source = _list;
_dataGrid.ItemsSource = _list;

问题是我有_dataGrid.SelectionChanged 事件,我只想在用户进行选择更改时触发它。但它正在触发该事件,因为 datagrid 默认选择第一项。

我会将事件切换到 leftMouseButtonDown,但这也不能很好地工作。有什么建议吗?

谢谢,

巫毒

【问题讨论】:

    标签: events silverlight-4.0 datagrid datapager


    【解决方案1】:

    尝试将“DataGrid.IsSynchronizedWithCurrentItem”设置为 false。我敢打赌这与此有关。由于您使用的是 CollectionView,因此 DataGrid 中的选定项目将与 CollectionView 的 CurrentItem 同步,当 CollectionView 初始化时,它会自动设置为第一个项目。

    【讨论】:

    • 不幸的是,Silverlight 的 DataGrid 中不存在该属性
    猜你喜欢
    • 1970-01-01
    • 2011-12-10
    • 2011-11-25
    • 1970-01-01
    • 1970-01-01
    • 2011-11-27
    • 2020-10-08
    • 2011-03-03
    • 1970-01-01
    相关资源
    最近更新 更多