1

静的ListCollectionViewにバインドされたデータグリッドがあります

CompassLogViewクラス:

        public static ListCollectionView Compasscollection {
        get {
            if (_compasscollection == null) {
                _compasscollection =
                    new ListCollectionView(LogSession.CompassLogCollection);
            }
            return _compasscollection;
        }
        set { _compasscollection = value; }
    }

バインディング

compassLogDataGrid.DataContext = CompassLogView.Compasscollection;

datagrid Xaml:

        <DataGrid x:Name="compassLogDataGrid"
              ItemsSource="{Binding}"
              SelectionMode="Single"
              IsSynchronizedWithCurrentItem="True"
              SelectedItem="{Binding Path=Synchronizer.CurrentCompassLogDataItem}"
              Style="{DynamicResource ResourceKey=dataGridStyle}">
              ...
</DataGrid>

SelectedItem(LINE 5)currentCompassLogDataItemは、クラス内のにバインドする必要がありますSynchronizer

試しましたが、無理そうです。助言がありますか?

4

1 に答える 1

1
<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:xmlnsで名前空間を指定します。これがお役に立てば幸いです。

于 2013-02-21T13:23:13.847 に答える