Posted 13 years ago
by SledgeHammer01
Version: 11.1.0543
Platform: .NET 4.0
Environment: Windows 7 (32-bit)
I'm using the MVVM features for creating document windows. My ItemsSource is the property:
public ObservableCollection<DocumentViewModelBase> Documents
At this time, I have one type of ViewModel: RangeViewDocVM.
I am mapping RangeViewDocVM -> RangeViewDocCtrl.xaml like this:
<DataTemplate DataType="{x:Type local:RangeViewDocVM}">
<local:RangeViewDocCtrl />
</DataTemplate>
When I add an item to the ItemsSource, everything seems to be created on first glance. Documents are added to the tabbed interface one on top of each other.
HOWEVER, it seems like only a single instance of RangeViewDocCtrl is created (unless I drag the windows around so they are in different docking containers).
This seems like a MAJOR flaw to me since now the RangeViewDocCtrl properties that are internal to the class and not bound to VM properties become shared across ALL the documents.
For example, lets say I have a ListView with column sorting.
Doc1 opens
Doc2 opens
Click Col1 on Doc1, now Doc2 is sorted on Col1
Click Col2 on Doc2, now Doc1 is sorted on Col2
All because they share the same instance of the control and it seems like you are just swapping out data contexts???
Also, going back to the list control or data grid, etc... the column width & arrangement would also be shared across all tabs... VERY weird.
[Modified at 06/24/2011 07:05 PM]
public ObservableCollection<DocumentViewModelBase> Documents
At this time, I have one type of ViewModel: RangeViewDocVM.
I am mapping RangeViewDocVM -> RangeViewDocCtrl.xaml like this:
<DataTemplate DataType="{x:Type local:RangeViewDocVM}">
<local:RangeViewDocCtrl />
</DataTemplate>
When I add an item to the ItemsSource, everything seems to be created on first glance. Documents are added to the tabbed interface one on top of each other.
HOWEVER, it seems like only a single instance of RangeViewDocCtrl is created (unless I drag the windows around so they are in different docking containers).
This seems like a MAJOR flaw to me since now the RangeViewDocCtrl properties that are internal to the class and not bound to VM properties become shared across ALL the documents.
For example, lets say I have a ListView with column sorting.
Doc1 opens
Doc2 opens
Click Col1 on Doc1, now Doc2 is sorted on Col1
Click Col2 on Doc2, now Doc1 is sorted on Col2
All because they share the same instance of the control and it seems like you are just swapping out data contexts???
Also, going back to the list control or data grid, etc... the column width & arrangement would also be shared across all tabs... VERY weird.
[Modified at 06/24/2011 07:05 PM]