私はあなたが定義したのviewmodelsとビューを持っているので、私はいくつかのビューを使用していた私は解決策を提案していますし、代わりにTreeViewコントロールの私がここにリストボックス、メインウィンドウで 、
<Grid>
<Grid.Resources>
<DataTemplate DataType="{x:Type my:AdvancedViewModel}">
<view:AdvancedView/>
</DataTemplate>
<DataTemplate DataType="{x:Type my:RegularViewModel}">
<view:RegularView/>
</DataTemplate>
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<ListBox ItemsSource="{Binding ViewModels}" SelectedItem="{Binding SelectedViewModel}" Grid.Column="0"/>
<ContentControl Content="{Binding SelectedViewModel}" Grid.Column="1"/>
</Grid>
を使用していると思いますそして、例えば、目的のために
ご意見、 最初のビュー
<UserControl x:Class="WpfApplication5.RegularView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WpfApplication5"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<TextBlock Text="Fom Regular"/>
</Grid>
をViewModelに
第二ビュー
<UserControl x:Class="WpfApplication5.AdvancedView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WpfApplication5"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<TextBlock Text="From Advanced"/>
</Grid>
とあなたのようでなければならないMainViewModel、
public class MainViewModel
{
private ObservableCollection<ViewModelBase> viewModels;
public ObservableCollection<ViewModelBase> ViewModels
{
get { return viewModels; }
set { viewModels = value; }
}
private ViewModelBase selectedViewModel;
public ViewModelBase SelectedViewModel
{
get { return selectedViewModel; }
set { selectedViewModel = value; }
}
public MainViewModel()
{
ViewModels = new ObservableCollection<ViewModelBase>();
ViewModels.Add(new RegularViewModel());
ViewModels.Add(new AdvancedViewModel());
SelectedViewModel = ViewModels[0];
}
}
public class ViewModelBase
{
}
public class RegularViewModel : ViewModelBase
{
}
public class AdvancedViewModel : ViewModelBase
{
}
はあなたの迅速な応答をありがとうございました。あなたはページの代わりに新しいusercontrolを作成します。それは私が探していたものではありませんが、私は今試してみます。 – Kleisophabo
これは一つのコンセプトです。あなたが望むコントロールを試すことができます。 – WPFUser
今私は概念を理解しなかった!そして私が探していたもの。あなたの答えをありがとう:D。私は、通常のビューと高度なビューについて混乱していました。私は今宿題を終えました。 :) – Kleisophabo