<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls">

    <Style TargetType="controls:MasterDetailsView">
        <Setter Property="Background" Value="{ThemeResource ApplicationPageBackgroundThemeBrush}" />
        <Setter Property="BorderBrush" Value="{ThemeResource ApplicationForegroundThemeBrush}" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="controls:MasterDetailsView">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <Grid x:Name="RootPanel">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition x:Name="MasterColumn"
                                                  Width="Auto" />
                                <ColumnDefinition x:Name="DetailsColumn"
                                                  Width="*" />
                            </Grid.ColumnDefinitions>
                            <Grid x:Name="MasterPanel"
                                  Width="{TemplateBinding MasterPaneWidth}"
                                  Background="{TemplateBinding MasterPaneBackground}"
                                  BorderBrush="{TemplateBinding BorderBrush}"
                                  BorderThickness="0,0,1,0">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="*" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>
                                <ContentPresenter x:Name="HeaderContentPresenter"
                                                  Margin="12,0"
                                                  x:DeferLoadStrategy="Lazy"
                                                  Content="{TemplateBinding MasterHeader}"
                                                  ContentTemplate="{TemplateBinding MasterHeaderTemplate}"
                                                  Visibility="Collapsed" />
                                <ListView x:Name="MasterList"
                                          Grid.Row="1"
                                          IsTabStop="False"
                                          ItemContainerStyle="{TemplateBinding ItemContainerStyle}"
                                          ItemTemplate="{TemplateBinding ItemTemplate}"
                                          ItemTemplateSelector="{TemplateBinding ItemTemplateSelector}"
                                          ItemsSource="{TemplateBinding ItemsSource}"
                                          SelectedItem="{Binding SelectedItem, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" />
                                <Grid x:Name="MasterCommandBarPanel" Grid.Row="2"></Grid>
                            </Grid>
                            <Grid x:Name="DetailsPanel"
                                  Grid.Column="1">
                                <ContentPresenter x:Name="NoSelectionPresenter"
                                                  Content="{TemplateBinding NoSelectionContent}"
                                                  ContentTemplate="{TemplateBinding NoSelectionContentTemplate}" />
                                <Grid x:Name="SelectionDetailsPanel">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="*" />
                                        <RowDefinition Height="Auto" />
                                    </Grid.RowDefinitions>
                                    <ContentPresenter x:Name="DetailsPresenter"
                                                  Background="{TemplateBinding Background}"
                                                  ContentTemplate="{TemplateBinding DetailsTemplate}">
                                    </ContentPresenter>
                                    <Grid x:Name="DetailsCommandBarPanel" Grid.Row="1"></Grid>
                                    <Grid.RenderTransform>
                                        <TranslateTransform x:Name="DetailsPresenterTransform" />
                                    </Grid.RenderTransform>
                                </Grid>
                            </Grid>
                        </Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="SelectionStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition From="NoSelectionWide"
                                                      To="HasSelection">
                                        <Storyboard>
                                            <DrillInThemeAnimation EntranceTargetName="SelectionDetailsPanel"
                                                                   ExitTargetName="NoSelectionPresenter" />
                                        </Storyboard>
                                    </VisualTransition>
                                    <VisualTransition From="NoSelectionNarrow"
                                                      To="HasSelection">
                                        <Storyboard>
                                            <DoubleAnimation BeginTime="0:0:0"
                                                             Storyboard.TargetName="DetailsPresenterTransform"
                                                             Storyboard.TargetProperty="X"
                                                             From="200"
                                                             To="0"
                                                             Duration="0:0:0.25">
                                                <DoubleAnimation.EasingFunction>
                                                    <QuarticEase EasingMode="EaseOut" />
                                                </DoubleAnimation.EasingFunction>
                                            </DoubleAnimation>
                                            <DoubleAnimation BeginTime="0:0:0"
                                                             Storyboard.TargetName="SelectionDetailsPanel"
                                                             Storyboard.TargetProperty="Opacity"
                                                             From="0"
                                                             To="1"
                                                             Duration="0:0:0.25">
                                                <DoubleAnimation.EasingFunction>
                                                    <QuarticEase EasingMode="EaseOut" />
                                                </DoubleAnimation.EasingFunction>
                                            </DoubleAnimation>
                                        </Storyboard>
                                    </VisualTransition>
                                    <VisualTransition From="HasSelection"
                                                      To="NoSelectionWide">
                                        <Storyboard>
                                            <DrillOutThemeAnimation EntranceTargetName="NoSelectionPresenter"
                                                                    ExitTargetName="SelectionDetailsPanel" />
                                        </Storyboard>
                                    </VisualTransition>
                                    <VisualTransition From="HasSelection"
                                                      To="NoSelectionNarrow">
                                        <Storyboard>
                                            <DoubleAnimation BeginTime="0:0:0"
                                                             Storyboard.TargetName="DetailsPresenterTransform"
                                                             Storyboard.TargetProperty="X"
                                                             From="0"
                                                             To="200"
                                                             Duration="0:0:0.25" />
                                            <DoubleAnimation BeginTime="0:0:0.08"
                                                             Storyboard.TargetName="SelectionDetailsPanel"
                                                             Storyboard.TargetProperty="Opacity"
                                                             From="1"
                                                             To="0"
                                                             Duration="0:0:0.17">
                                                <DoubleAnimation.EasingFunction>
                                                    <QuarticEase EasingMode="EaseOut" />
                                                </DoubleAnimation.EasingFunction>
                                            </DoubleAnimation>
                                        </Storyboard>
                                    </VisualTransition>
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="NoSelectionWide">
                                    <VisualState.Setters>
                                        <Setter Target="SelectionDetailsPanel.Visibility" Value="Collapsed" />
                                    </VisualState.Setters>
                                </VisualState>
                                <VisualState x:Name="HasSelection">
                                    <VisualState.Setters>
                                        <Setter Target="NoSelectionPresenter.Visibility" Value="Collapsed" />
                                    </VisualState.Setters>
                                </VisualState>
                                <VisualState x:Name="NoSelectionNarrow">
                                    <VisualState.Setters>
                                        <Setter Target="NoSelectionPresenter.Visibility" Value="Collapsed" />
                                        <Setter Target="SelectionDetailsPanel.Visibility" Value="Collapsed" />
                                    </VisualState.Setters>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="WidthStates">
                                <VisualState x:Name="NarrowState">
                                    <VisualState.StateTriggers>
                                        <AdaptiveTrigger MinWindowWidth="320" />
                                    </VisualState.StateTriggers>
                                    <VisualState.Setters>
                                        <Setter Target="MasterColumn.Width" Value="*" />
                                        <Setter Target="DetailsColumn.Width" Value="0" />
                                        <Setter Target="DetailsPanel.(Grid.Column)" Value="0" />
                                        <Setter Target="NoSelectionPresenter.Visibility" Value="Collapsed" />
                                        <Setter Target="MasterPanel.BorderThickness" Value="0" />
                                        <Setter Target="MasterPanel.Width" Value="NaN" />
                                    </VisualState.Setters>
                                </VisualState>
                                <VisualState x:Name="WideState">
                                    <VisualState.StateTriggers>
                                        <AdaptiveTrigger MinWindowWidth="720" />
                                    </VisualState.StateTriggers>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>

