回答編集履歴
1
質問文変更につき回答内容を変更しました。
    
        answer	
    CHANGED
    
    | @@ -1,19 +1,12 @@ | |
| 1 | 
            -
            ```XAML
         | 
| 2 | 
            -
            <Window x:Class="SampleApp.MainWindow"
         | 
| 3 | 
            -
                    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         | 
| 4 | 
            -
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         | 
| 5 | 
            -
                    xmlns:local="clr-namespace:SampleApp"
         | 
| 6 | 
            -
                    Title="MainWindow" Height="100" Width="200">
         | 
| 7 | 
            -
                <Grid>
         | 
| 8 | 
            -
             | 
| 1 | 
            +
            自分なら A と B をあらかじめ配置、Visibility.Collapsed にしておいて、
         | 
| 2 | 
            +
            ボタンクリックなどのタイミングで Style.Triggers で
         | 
| 9 | 
            -
             | 
| 3 | 
            +
            Visibility を入れ替えるようにします。
         | 
| 10 | 
            -
            </Window>
         | 
| 11 | 
            -
            ```
         | 
| 12 4 |  | 
| 13 | 
            -
            プレフィックスってもしかして上記コードの
         | 
| 14 | 
            -
            「xmlns:local="clr-namespace:SampleApp"」の「local」や「SampleApp」のことでしょうか。
         | 
| 15 | 
            -
             | 
| 5 | 
            +
            A および B の内容が大きい場合は
         | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 6 | 
            +
            MainWindow のデータコンテキストに CurrentViewModel みたいなプロパティを用意し、
         | 
| 18 | 
            -
             | 
| 7 | 
            +
            A と B それぞれに ViewModel を用意します。
         | 
| 8 | 
            +
            ContentControl の Content プロパティに CurrentViewModel をバインドし、
         | 
| 9 | 
            +
            ボタンクリックのコマンドから CurrentViewModel を A から B、B から A 用のものに入れ替えます。
         | 
| 10 | 
            +
            CurrentViewModel をバインドされた ContentControl はそのままでは UI を表示できないので、
         | 
| 19 | 
            -
             | 
| 11 | 
            +
            App.Resources などに DataTemplate を定義し、
         | 
| 12 | 
            +
            A の ViewModel のときは A、B の ViewModel のときは B が表示されるようにします。
         | 
