たぶん、このリンクが役に立ちます。NavigateToウィンドウに表示する必要があるビューにプロパティを設定するだけです。
例として、次のようなことができます
<Window x:Class="MainWindowView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:meffed="http:\\www.codeplex.com\MEFedMVVM"
meffed:ViewModelLocator.NonSharedViewModel="YourViewModel"
WindowStartupLocation="CenterScreen">
<Button meffed:NavigationExtensions.NavigateTo="firstview"
meffed:NavigationExtensions.NavigationHost="{Binding ElementName=_viewContainer}"
meffed:NavigationExtensions.NavigateOnceLoaded="False"
Visibility="Visible" />
<ContentControl x:Name="_viewContainer" Margin="0,0,0,10" />
<Window>
次に、クラスファイルは次のようになります
public partial class MainWindowView : Window
{
public MainWindowView()
{
InitializeComponent();
}
public ContentControl ViewContainer { get { return _viewContainer; } }
}
次に、各ビューを として定義UserControlし、上記のリンクを使用してボタンの をバインドできますmeffed:NavigationExtensions.NavigateTo="secondView"。をターゲットにするContentControlには、バインディングWindowを使用するだけです。RelativeSource例えば
meffed:NavigationExtensions.NavigationHost="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}},Path=ViewContainer}"
それぞれのビューで、コード ビハインド クラス定義に などの注釈を付けていることがわかります[NavigationView("firstview")]。
初めては複雑ですが、考え方が分かればとても簡単です。