<
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}" />
<
UserControl
x:Class
=
"MyAppDesktopWPF.TreeviewView"
xmlns:Telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"
xmlns:csla="clr-namespace:Csla.Data;assembly=Csla"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400"
Loaded="UserControl_Loaded"
xmlns:my="clr-namespace:MyAppDesktopWPF.ViewModels">
<
UserControl.Resources
>
<
CollectionViewSource
x:Key
=
"TreeAreaDS"
Source="{Binding
Source={StaticResource TrashViewModel},
Path
=
Model
}"></
CollectionViewSource
>
<
HierarchicalDataTemplate
x:Key
=
"ToolsDataTemplate"
ItemsSource
=
"{Binding Tools}"
>
<
TextBlock
Text
=
"{Binding Path=Name}"
FontWeight
=
"Bold"
/>
</
HierarchicalDataTemplate
>
<
HierarchicalDataTemplate
x:Key
=
"SegmentsDataTemplate"
ItemsSource
=
"{Binding Segments}"
ItemTemplate="{StaticResource ToolsDataTemplate}" >
<
TextBlock
Text
=
"{Binding Path=Name}"
FontWeight
=
"Bold"
/>
</
HierarchicalDataTemplate
>
<
HierarchicalDataTemplate
x:Key
=
"SectionsDataTemplate"
ItemsSource
=
"{Binding Sections}"
ItemTemplate="{StaticResource
SegmentsDataTemplate}">
<
TextBlock
Text
=
"{Binding Path=Name}"
FontWeight
=
"Bold"
/>
</
HierarchicalDataTemplate
>
</
UserControl.Resources
>
<
Telerik:RadTreeView
ItemsSource="{Binding Source={StaticResource
TreeAreaDS}}"
ItemTemplate
=
"{StaticResource SectionsDataTemplate}"
Name
=
"PlanTreeView"
Height
=
"250"
HorizontalAlignment
=
"Left"
Margin
=
"3"
VerticalAlignment
=
"Center"
Width
=
"150"
/>
public class TrashViewModel : ViewModel<
MyAppBO.MyClass
>
{
public TrashViewModel()
{
Bxf.Shell.Instance.ShowStatus(new Bxf.Status { Text =
"Getting Plan", IsBusy = true });
ManageObjectLifetime = true;
// cascade model changed events through VM to View
Model.PropertyChanged += (o, e) =>
OnPropertyChanged(e.PropertyName);
}
public TrashViewModel(MyClass classInstance)
{
Bxf.Shell.Instance.ShowStatus(new Bxf.Status { Text =
"Getting Plan", IsBusy = true });
ManageObjectLifetime = true;
Model = classInstance;
// cascade model changed events through VM to View<
br
>
Model.PropertyChanged += (o, e) =>
OnPropertyChanged(e.PropertyName);
}
<
CollectionViewSource
x:Key
=
"TreeAreaDS"
Source
=
"TrashViewModel"
>
</
CollectionViewSource
>
<
Style
TargetType
=
"{x:Type telerik:GridViewFooterCell}"
>
<
Setter
Property
=
"HorizontalAlignment"
Value
=
"Right"
/>
</
Style
>