Reputation: 1070
I have a datagrid binded to a static ListCollectionView
CompassLogView class:
public static ListCollectionView Compasscollection {
get {
if (_compasscollection == null) {
_compasscollection =
new ListCollectionView(LogSession.CompassLogCollection);
}
return _compasscollection;
}
set { _compasscollection = value; }
}
The Binding
compassLogDataGrid.DataContext = CompassLogView.Compasscollection;
the datagrid Xaml:
<DataGrid x:Name="compassLogDataGrid"
ItemsSource="{Binding}"
SelectionMode="Single"
IsSynchronizedWithCurrentItem="True"
SelectedItem="{Binding Path=Synchronizer.CurrentCompassLogDataItem}"
Style="{DynamicResource ResourceKey=dataGridStyle}">
...
</DataGrid>
the SelectedItem
(LINE 5) must be bound to currentCompassLogDataItem
which is in Synchronizer
class.
I have tried but it seems impossible. any suggestions?
Upvotes: 1
Views: 173
Reputation: 12295
<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: specifies the namespace in xmlns.I hope this will help
Upvotes: 1