<common:LayoutAwarePage
    x:Name="pageRoot"
    x:Class="BadanieZdarzenTrasowanych.MainPage"
    DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:BadanieZdarzenTrasowanych"
    xmlns:common="using:BadanieZdarzenTrasowanych.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Page.Resources>
        <x:String x:Key="AppName">Poznajemy zdarzenia trasowane</x:String>
    </Page.Resources>

    <!--
        This grid acts as a root panel for the page that defines two rows:
        * Row 0 contains the back button and page title
        * Row 1 contains the rest of the page layout
    -->
    <Grid Style="{StaticResource LayoutRootStyle}">
        <Grid.RowDefinitions>
            <RowDefinition Height="140"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <Grid Grid.Row="1" Margin="120,0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <StackPanel x:Name="panel" PointerPressed="StackPanel_PointerPressed">
                <Border BorderThickness="10" BorderBrush="Blue" Width="155" x:Name="border"
                Margin="20" PointerPressed="Border_PointerPressed">
                    <Grid x:Name="grid" PointerPressed="Grid_PointerPressed">
                        <Ellipse Fill="Red"  Width="100" Height="100" 
                      PointerPressed="Ellipse_PointerPressed"/>
                        <Rectangle Fill="Gray" Width="50" Height="50"
                      PointerPressed="Rectangle_PointerPressed" x:Name="grayRectangle"/>
                    </Grid>
                </Border>
                <ListBox BorderThickness="1" Width="300" Height="250" x:Name="output" Margin="0,0,20,0"/>
            </StackPanel>
            <StackPanel Grid.Column="1">
                <ToggleSwitch Header="Obsłużone w kontrolce Border" x:Name="borderSetsHandled" OffContent="Wyłączone" OnContent="Włączone"/>
                <ToggleSwitch Header="Obsłużone w kontrolce Grid" x:Name="gridSetsHandled" OffContent="Wyłączone" OnContent="Włączone" />
                <ToggleSwitch Header="Obsłużone w kontrolce Ellipse" x:Name="ellipseSetsHandled" OffContent="Wyłączone" OnContent="Włączone"/>
                <ToggleSwitch Header="Obsłużone w kontrolce Rectangle" x:Name="rectangleSetsHandled" OffContent="Wyłączone" OnContent="Włączone"/>
                <Button Content="Zaktualizuj właściwość IsHitTestVisible Rectangle "
               Click="UpdateHitTestButton" Margin="0,20,20,0"/>
                <ToggleSwitch IsOn="True" Header="Nowa wartość właściwośći IsHitTestVisible" x:Name="newHitTestVisibleValue" OffContent="Wyłączona" OnContent="Włączona" />
            </StackPanel>
        </Grid>

        <!-- Back button and page title -->
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}"/>
            <TextBlock x:Name="pageTitle" Grid.Column="1" Text="{StaticResource AppName}" Style="{StaticResource PageHeaderTextStyle}"/>
        </Grid>

        <VisualStateManager.VisualStateGroups>

            <!-- Visual states reflect the application's view state -->
            <VisualStateGroup x:Name="ApplicationViewStates">
                <VisualState x:Name="FullScreenLandscape"/>
                <VisualState x:Name="Filled"/>

                <!-- The entire page respects the narrower 100-pixel margin convention for portrait -->
                <VisualState x:Name="FullScreenPortrait">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PortraitBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>

                <!-- The back button and title have different styles when snapped -->
                <VisualState x:Name="Snapped">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="pageTitle" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedPageHeaderTextStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>
</common:LayoutAwarePage>
