I have the following set up in my Application.xaml:
<
P
><
DataTemplate
DataType
=
"{x:Type vm:DeviceInventoryListViewModel}"
>
<
BR
> <
local:DeviceInventoryList
/> <
BR
></
DataTemplate
>
<
BR
><
DataTemplate
DataType
=
"{x:Type vm:AccountMaintenanceListViewModel}"
>
<
BR
> <
local:AccountMaintenanceList
/> <
BR
></
DataTemplate
></
P
>
My ShellViewModel is as follows:
Public Class ShellViewModel
Inherits ViewModelBase
Private _openviews As ObservableCollection(Of ViewModelBase)
Private _currentview As ViewModelBase
Public ReadOnly Property Views As ObservableCollection(Of ViewModelBase)
Get
If _openviews Is Nothing Then
_openviews = New ObservableCollection(Of ViewModelBase)
AddHandler _openviews.CollectionChanged, AddressOf ViewCollectionChanged
LoadDefaultViews()
End If
Return _openviews
End Get
End Property
Private Sub LoadDefaultViews()
_openviews.Add(New DeviceInventoryListViewModel)
_openviews.Add(New AccountMaintenanceListViewModel)
_currentview = _openviews.Item(0)
End Sub
Public Property SelectedView As ViewModelBase
Get
Return _currentview
End Get
Set(ByVal value As ViewModelBase)
_currentview = value
OnPropertyChanged("SelectedView")
End Set
End Property
End Class
And then my ShellView has its DataContext set to an instance of my ShellViewmodel and the XAML contains the following:
<
telerik:RadTabControl
Grid.Row
=
"1"
ItemsSource
=
"{Binding Views}"
SelectedItem="{Binding SelectedView}" />