<Page x:Class="ViewSwitchingSample.MainPage"
      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:local="using:ViewSwitchingSample"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:triggers="using:ViewSwitchingSample.Triggers"
      xmlns:views="using:ViewSwitchingSample.Views"
      mc:Ignorable="d">
    <Page.Resources>
        <DataTemplate x:Key="DataTemplate.View.Desktop">
            <views:DesktopView />
        </DataTemplate>
        <DataTemplate x:Key="DataTemplate.View.Phone">
            <views:PhoneView />
        </DataTemplate>
    </Page.Resources>
    <Border>
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="CommonStates">
                <!--
                    Depending on the DeviceFamily the views are swapped into the ContentPresenter.
                -->
                <VisualState x:Name="DeviceFamilyDesktop">
                    <VisualState.StateTriggers>
                        <triggers:DeviceFamilyTrigger DeviceFamily="Desktop" />
                    </VisualState.StateTriggers>
                    <VisualState.Setters>
                        <Setter Target="ViewRegion.ContentTemplate" Value="{StaticResource DataTemplate.View.Desktop}" />
                    </VisualState.Setters>
                </VisualState>
                <VisualState x:Name="DeviceFamilyPhone">
                    <VisualState.StateTriggers>
                        <triggers:DeviceFamilyTrigger DeviceFamily="Mobile" />
                    </VisualState.StateTriggers>
                    <VisualState.Setters>
                        <Setter Target="ViewRegion.ContentTemplate" Value="{StaticResource DataTemplate.View.Phone}" />
                    </VisualState.Setters>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
        <ContentPresenter x:Name="ViewRegion" />
    </Border>
</Page>

