Closed SAgiKPJH closed 9 months ago
예시
<ContentPresenter Content="{Binding YouTypeHere}">
<ContentPresenter.Resources>
<DataTemplate DataType="{x:Type fristViewModel1Type}">
<youControlForViewModel1 />
</DataTemplate>
<DataTemplate DataType="{x:Type secondViewModel2Type}">
<youControlForViewModel2 />
</DataTemplate>
</ContentPresenter.Resources>
</ContentPresenter>
<Window.Resources>
<DataTemplate DataType="{x:Type home:HomeViewModel}">
<home:HomeView />
</DataTemplate>
<DataTemplate DataType="{x:Type other:OtherViewModel}">
<other:OtherView />
</DataTemplate>
</Window.Resources>
<Grid x:Name="MainContent" Grid.Row="1">
<ContentControl Content="{Binding CurrentViewModel}" />
</Grid>
<Window.Resources>
<DataTemplate DataType="{x:Type home:HomeViewModel}">
<home:HomeView />
</DataTemplate>
<DataTemplate DataType="{x:Type other:OtherViewModel}">
<other:OtherView />
</DataTemplate>
</Window.Resources>
<Grid x:Name="MainContent" Grid.Row="1">
<ContentControl Content="{Binding CurrentViewModel}" />
</Grid>
// App.xaml.cs
MainView mainView = new MainView(); mainView.Show(); mainView.Closing += (o, e) => CloseMethod();