首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >数据网格数据绑定

数据网格数据绑定
EN

Stack Overflow用户
提问于 2013-02-21 20:49:51
回答 1查看 160关注 0票数 1

我有一个绑定到静态ListCollectionView的数据网格

CompassLogView类:

代码语言:javascript
复制
        public static ListCollectionView Compasscollection {
        get {
            if (_compasscollection == null) {
                _compasscollection =
                    new ListCollectionView(LogSession.CompassLogCollection);
            }
            return _compasscollection;
        }
        set { _compasscollection = value; }
    }

绑定

代码语言:javascript
复制
compassLogDataGrid.DataContext = CompassLogView.Compasscollection;

数据网格Xaml:

代码语言:javascript
复制
        <DataGrid x:Name="compassLogDataGrid"
              ItemsSource="{Binding}"
              SelectionMode="Single"
              IsSynchronizedWithCurrentItem="True"
              SelectedItem="{Binding Path=Synchronizer.CurrentCompassLogDataItem}"
              Style="{DynamicResource ResourceKey=dataGridStyle}">
              ...
</DataGrid>

SelectedItem (第5行)必须绑定到Synchronizer类中的currentCompassLogDataItem

我试过了,但似乎不可能。有什么建议吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-02-21 21:23:14

代码语言:javascript
复制
<DataGrid x:Name="compassLogDataGrid"
          ItemsSource="{Binding}"
          SelectionMode="Single"
          IsSynchronizedWithCurrentItem="True"
          SelectedItem="{Binding Path=CurrentCompassLogDataItem,Source={StaticResource synchronizer} }"
          Style="{DynamicResource ResourceKey=dataGridStyle}">
        <DataGrid.Resources>
            <local:Synchronizer x:Key="synchronizer"/>
        </DataGrid.Resources>
    </DataGrid>

local:在will中指定名称空间。我希望这会有所帮助

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15002685

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档