Avalonia style in Grid? - avaloniaui

Why can I not add this style into Grid.Resource
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="HelloAva.GreetingWindow"
Title="HelloAva">
<Window.Styles>
<Style Selector="TextBlock">
<Setter Property="FontSize" Value="30" />
</Style>
</Window.Styles>
<Grid ShowGridLines="True">
<!-- <Grid.Resources> -->
<!-- <Style Selector="TextBlock"> -->
<!-- <Setter Property="FontSize" Value="30"> -->
<!-- </Setter> -->
<!-- </Style> -->
<!-- </Grid.Resources> -->
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="2*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Background="LightGray" Text="Something">
</TextBlock>
<TextBlock Background="LightGray"
Text="FooBar"
Grid.Row="1" Grid.Column="1">
</TextBlock>
<TextBlock Background="LightGray"
Text="FooBar"
Grid.Row="2" Grid.Column="0">
</TextBlock>
</Grid>
</Window>

It has to be added to the Styles collection, not to the Resources.

Related

Overlay element over ContentControl's ContentPresenter

I am trying to get this seemingly simple scenario to work.
I have a ContentControl MyControl, and I would like one of it's elements to overflow on top of the ContentPresenter while remaining an element of a border.
<Page
x:Class="Playground.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Playground"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="using:Playground"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Page.Resources>
<Style TargetType="local:MyControl" >
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:MyControl">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="100"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Border Grid.Row="0" BorderBrush="GreenYellow" BorderThickness="1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Rectangle Grid.Column="0" Width="50" Height="50" Fill="Silver" HorizontalAlignment="Center"/>
<Rectangle x:Name="Overflow" Grid.Column="1" Width="100" Height="200" Fill="Gold" HorizontalAlignment="Center"/>
<Rectangle Grid.Column="2" Width="50" Height="50" Fill="Silver" HorizontalAlignment="Center"/>
</Grid>
</Border>
<ContentPresenter Grid.Row="1"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Page.Resources>
<controls:MyControl Grid.Row="0" BorderBrush="Gold" BorderThickness="1">
<Ellipse Fill="Silver"/>
</controls:MyControl>
</Page>
I have tried playing with Canvas.ZIndex but I cannot get this particular scenario to work. Just to re-iterate, I would like the gold rectangle to overflow over all of the content in the ContentPresenter, but I would like the border and two squares to remain as they are.
Edit: The source for this project is here if anybody s interested in playing with it.
So you want the middle rectangle to be a part of your border but it should go out of the border bounds?
For this you can only use negative Margin.
In order to overlay the content you border should be the second child of the the parents Grid.
sumarizing everithing we have:
<Style TargetType="local:MyControl">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:MyControl">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="100" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<ContentPresenter Grid.Row="1" />
<Border
Grid.Row="0"
BorderBrush="GreenYellow"
BorderThickness="1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Rectangle
Grid.Column="0"
Width="50"
Height="50"
HorizontalAlignment="Center"
Fill="Silver" />
<!--Pay attention to Margin="0,0,0,-100"-->
<Rectangle
x:Name="Overflow"
Grid.Column="1"
Width="100"
Height="200"
Margin="0,0,0,-100"
HorizontalAlignment="Center"
Fill="Gold" />
<Rectangle
Grid.Column="2"
Width="50"
Height="50"
HorizontalAlignment="Center"
Fill="Silver" />
</Grid>
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Hacky workaround I came up with - problem is the rectangle is no longer part of the border and as such can't be easily laid out with respect to the border.
<Page
x:Class="Playground.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Playground"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="using:Playground"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Page.Resources>
<Style TargetType="local:MyControl" >
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:MyControl">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="100"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ContentPresenter Grid.Row="1"/>
<Border Grid.Row="0" BorderBrush="GreenYellow" BorderThickness="1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Rectangle Grid.Column="0" Width="50" Height="50" Fill="Silver" HorizontalAlignment="Center"/>
<Rectangle Grid.Column="2" Width="50" Height="50" Fill="Silver" HorizontalAlignment="Center"/>
</Grid>
</Border>
<Rectangle Grid.Row="0" Grid.RowSpan="2" x:Name="Overflow" Grid.Column="1" Width="100" Height="200" Fill="Gold" HorizontalAlignment="Center" VerticalAlignment="Top"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Page.Resources>
<controls:MyControl Grid.Row="0" BorderBrush="Gold" BorderThickness="1">
<Ellipse Fill="Silver"/>
</controls:MyControl>
</Page>

WPF Control Background

My WPF control background color is not working in my Universal Windows app. Here is the xaml. The Grid background is working fine, for both grids. The content TextBlocks in the ItemsControl do appear. What am I missing?
<Page
x:Class="Jockusch.Calculator.WindowsStore.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Jockusch.Calculator.WindowsStore"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:system="using:System"
mc:Ignorable="d">
<Page.TopAppBar>
<CommandBar x:Name="TabBar" IsOpen="True" IsSticky="True">
<CommandBar.PrimaryCommands>
<AppBarButton Margin="100,0,0,0" HorizontalAlignment="Left" HorizontalContentAlignment="Right" IsEnabled="True" Name="btnNext" Icon="Next" x:Uid="AppBarNext" Label="Next1"></AppBarButton>
</CommandBar.PrimaryCommands>
</CommandBar>
</Page.TopAppBar>
<Grid Background="Yellow">
<Grid.Resources>
<Style TargetType="ItemsControl">
<Setter Property="Background" Value="Wheat">
</Setter>
</Style>
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="299" />
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="366"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="200"/>
</Grid.RowDefinitions>
<local:WindowsAdAndContentWrapperView Background="Orange" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" x:Name="ContentView"></local:WindowsAdAndContentWrapperView>
<Grid Background="Brown" Grid.Row="0" Grid.Column="1"/>
<ItemsControl Grid.Row="0" Grid.Column="2">
<ItemsControl.Items>
<TextBlock Text="Hello"></TextBlock>
<TextBlock Text="Where are my colors?"/>
</ItemsControl.Items>
</ItemsControl>
</Grid>
</Page>

Grid not covering all the screen in UWP app

Why my grid is not covering all the screen and how can i fix it? On the designer looks like it should be covering all the width of the screen, but actually leaves a big space on the rigth.
<Grid Background="GreenYellow">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="200"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
</Grid>
This code is only a snip, but even with childs the space its there on different sizes.
Edit 1:
Acoording to Luis C. answer i get the same result big empty space to the left:
I found a strange workaround to achieve what i want:
<Grid Background="Yellow">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="200"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<TextBlock Text="This is a very large text that only is used to strech all the childrens to the infinite. This is a very large text that only is used to strech all the childrens to the infinite. This is a very large text that only is used to strech all the childrens to the infinite. This is a very large text that only is used to strech all the childrens to the infinite. This is a very large text that only is used to strech all the childrens to the infinite" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
<Button Content="Black" Background="Black" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
</Grid>
<Button Grid.Row="1" Content="Black" Background="Gray" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
<Button Grid.Row="2" Content="Black" Background="Blue" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
</Grid>
The result is:
Still its a very strange way to workaround the problem.
Full Code
As you see, im using a SplitView on a GridView that loads Pages(like the one with the mentioned problem) on a Frame inside the SplitViewContent. Other Pages with TextBlock as childrens cover the whole screen as i want. The code for the SplitView is:
<Page
x:Class="MyProject.ViewModels.HomePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MyProject.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<RelativePanel>
<Button Name="HamburgerButton" FontFamily="Segoe MDL2 Assets" Content="" FontSize="36" Click="HamburgerButton_Click" Background="LightGray"/>
<!--<Button Name="BackButton" FontFamily="Segoe MDL2 Assets" Content="" FontSize="36" Visibility="Visible" Background="LightGray"/>-->
<CommandBar Name="Bar" RelativePanel.AlignRightWithPanel="True" ClosedDisplayMode="Compact" RelativePanel.RightOf="HamburgerButton" Visibility="Visible" Background="LightGray" IsOpen="False" IsSticky="True" >
<CommandBar.Content>
<TextBlock Name="BarTitle" Text="Title" FontSize="24" Margin="24,8,0,12" HorizontalAlignment="Center" VerticalAlignment="Center" />
</CommandBar.Content>
</CommandBar>
</RelativePanel>
<SplitView Name="MySplitView"
Grid.Row="1"
DisplayMode="Overlay"
OpenPaneLength="200"
CompactPaneLength="56"
HorizontalAlignment="Left">
<SplitView.Pane>
<ListBox SelectionMode="Single"
Name="IconsListBox"
SelectionChanged="IconsListBox_SelectionChanged">
<ListBoxItem Name="SymbolsListBoxItem">
<StackPanel Orientation="Horizontal">
<Image Source="x" Width="36" Height="36" HorizontalAlignment="Center" VerticalAlignment="Center"> </Image>
<TextBlock x:Uid="Symbols" Text="[Symbols]" FontSize="24" Margin="20,0,0,0" />
</StackPanel>
</ListBoxItem>
</ListBox>
</SplitView.Pane>
<SplitView.Content >
<Frame Name="FrameHolder"></Frame>
</SplitView.Content>
</SplitView>
<Frame Name="HomePageFrame" >
<!-- Frame not used by now-->
</Frame>
</Grid>
The full code page snippet is(with more children) and the result the same, big blank empty space to the right:
<Page
x:Class="MyProject.ViewModels.SymbolsPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MyProject.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:data="using:MyProject.Models"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Page.Resources>
<Style TargetType="ListView" x:Key="myListViewStyle">
<Setter Property="AllowDrop" Value="False" />
<Setter Property="CanReorderItems" Value="False" />
<Setter Property="Width" Value="36"/>
<Setter Property="Height" Value="140"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="Padding" Value="0,4,0,0"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden" />
<Setter Property="BorderBrush" Value="White" />
<Setter Property="BorderThickness" Value="1" />
</Style>
<Style TargetType="TextBlock" x:Key="SymbolViewer">
<Setter Property="FontFamily" Value="/Fonts/etc"/>
<Setter Property="FontSize" Value="30" />
<Setter Property="Padding" Value="8"/>
<Setter Property="TextAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
<LinearGradientBrush x:Key="GradBackground" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="LightGray" Offset="0"/>
<GradientStop Color="White" Offset=".5"/>
<GradientStop Color="LightGray" Offset="1"/>
</LinearGradientBrush>
<LinearGradientBrush x:Key="ItemGradBackground" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="White" Offset="0"/>
<GradientStop Color="White" Offset=".5"/>
<GradientStop Color="LightGray" Offset="1"/>
</LinearGradientBrush>
</Page.Resources>
<!-- Spinners -->
<StackPanel Background="AliceBlue" HorizontalAlignment="Stretch" Padding="0">
<StackPanel Background="{StaticResource GradBackground}" >
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center" >
<ListView Name="Uno" ItemsSource="{x:Bind UnoItems}" Style="{StaticResource myListViewStyle}" BorderBrush="White"
BorderThickness="2" IsItemClickEnabled="True" ItemClick="Uno_ItemClick">
<ListView.ItemTemplate >
<DataTemplate x:DataType="data:Thingy">
<TextBlock Text="{x:Bind Symbol}" FontFamily="/Fonts/etc"></TextBlock>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<!-- Not user interactive-->
<TextBlock Text="0" Width="36" HorizontalAlignment="Center" VerticalAlignment="Center" TextAlignment="Center" ></TextBlock>
<!-- Spinner 2 -->
<ListView Name="Dos" ItemsSource="{x:Bind DosItems}" Style="{StaticResource myListViewStyle}"
IsItemClickEnabled="True" ItemClick="Dos_ItemClick">
<ListView.ItemTemplate >
<DataTemplate x:DataType="data:Thingy">
<TextBlock Text="{x:Bind Symbol}" ></TextBlock>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<ListView Name="Tres" ItemsSource="{x:Bind TresItems}" Style="{StaticResource myListViewStyle}">
<ListView.ItemTemplate >
<DataTemplate x:DataType="data:Thingy">
<TextBlock Text="{x:Bind Symbol}" ></TextBlock>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<ListView Name="Cuatro" ItemsSource="{x:Bind TresItems}" Style="{StaticResource myListViewStyle}">
<ListView.ItemTemplate >
<DataTemplate x:DataType="data:Thingy">
<TextBlock Text="{x:Bind Symbol}" ></TextBlock>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<ListView Name="Cinco" ItemsSource="{x:Bind DosItems}" Style="{StaticResource myListViewStyle}">
<ListView.ItemTemplate >
<DataTemplate x:DataType="data:Thingy">
<TextBlock Text="{x:Bind Symbol}" ></TextBlock>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<ListView Name="Seiss" ItemsSource="{x:Bind TresItems}" Style="{StaticResource myListViewStyle}">
<ListView.ItemTemplate >
<DataTemplate x:DataType="data:Thingy">
<TextBlock Text="{x:Bind Symbol}"></TextBlock>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackPanel>
</StackPanel>
</StackPanel>
You just need to remove the "RowDefinition" without height and change the "Auto" Rows to "*".
Something like this:
<Grid Background="GreenYellow">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="200"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Button Grid.Row="0" Content="Black" Background="Black" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
<Button Grid.Row="1" Content="Black" Background="Gray" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
<Button Grid.Row="2" Content="Black" Background="Blue" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
</Grid>

XAML Element responsive width on Orientation change

I am building a Windows 8.1 Universal app. On the orientation change for the phone, the outer "Grid" element doesn't change in width when the phone is switched to Landscape mode (and vice versa if the app is originally opened in landscape - doesn't change width when orientation=portrait). The Width is bound to the PivotItem Width and the PivotItem fills the entire screen on orientation change but the Grid does not.
<Page x:Name="page"
x:Class="App1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App1"
xmlns:m="using:App1.Models"
xmlns:vm="using:App1.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
mc:Ignorable="d">
<Page.BottomAppBar>
<CommandBar Foreground="White" Background="{StaticResource CustomResource}">
<AppBarButton x:Name="BackButton" Label="Back" HorizontalAlignment="Center"
Click="BackButton_Click" Icon="Back" />
<AppBarButton x:Name="ForwardButton" Label="Forward" HorizontalAlignment="Center"
Click="ForwardButton_Click" Icon="Forward" />
<AppBarButton x:Name="HomeButton" Label="Home" HorizontalAlignment="Center"
Click="HomeButton_Click" Icon="Home" />
<AppBarButton x:Name="SettingsButton" Label="Settings" HorizontalAlignment="Center"
Click="SettingsButton_Click" Icon="Setting" />
</CommandBar>
</Page.BottomAppBar>
<Page.Resources>
<DataTemplate x:Key="myHeader">
<TextBlock Text="{Binding}" FontFamily="CustomFont" />
</DataTemplate>
<Style x:Key="PivotStyle" TargetType="Pivot">
<Setter Property="HeaderTemplate" Value="{StaticResource myHeader}"/>
</Style>
<!--<dict:NumberConverter x:Key="myNumberConverter" />-->
</Page.Resources>
<d:Page.DataContext>
<vm:DesignTimeDataSample />
</d:Page.DataContext>
<Grid>
<Pivot x:Name="MyPivot"
Style="{StaticResource PivotStyle}"
Background="{StaticResource CustomItem}"
SelectionChanged="MyPivot_SelectionChanged"
Foreground="Purple"
Grid.Row="1">
<PivotItem x:Name="Feed"
Header="news feed"
FontFamily="CustomFont">
<ScrollViewer Name="ScrollViewer">
<StackPanel x:Name="stackPanel">
<ListView ItemsSource="{Binding TileStories}" x:Name="cont" Margin="0,10,0,10" Background="{StaticResource CustomItem}" BorderBrush="{StaticResource CustomItem}" Foreground="{StaticResource CustomItem}">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="MinHeight" Value="0" />
<Setter Property="Margin" Value="0,10,0,10" />
<Setter Property="Foreground" Value="{StaticResource CustomItem}" />
</Style>
</ListView.ItemContainerStyle>
<ListView.ItemTemplate>
<DataTemplate>
<Border CornerRadius="20" BorderThickness="0" Background="White" HorizontalAlignment="Stretch">
<StackPanel Height="160" Orientation="Horizontal">
<Grid HorizontalAlignment="Stretch" Width="{Binding ActualWidth, ElementName=Feed, Mode=OneWay}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="2*" />
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<Image Source="{Binding ImagePath}" Margin="20"/>
</Grid>
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="2*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid Grid.Row="0" Margin="0,0,0.333,53" Grid.RowSpan="2" HorizontalAlignment="Stretch">
<TextBlock VerticalAlignment="Center"
LineStackingStrategy="BlockLineHeight"
LineHeight="20" MaxHeight="80"
TextWrapping="WrapWholeWords"
Text="{Binding Headline}" FontSize="18"
FontFamily="CustomItem" />
</Grid>
<Grid Grid.Row="1" Margin="0,0.333,0.333,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<TextBlock VerticalAlignment="Center"
HorizontalAlignment="Left"
Margin="5" Text="{Binding Date}"
Foreground="#FFBDBDBD"
FontFamily="CustomItem" />
</Grid>
<Grid Grid.Column="1">
<AppBarButton
Style="{StaticResource CustomItem}"
VerticalAlignment="Center"
Margin="0,0,0,2"
HorizontalAlignment="Right"
Icon="Read"
CommandParameter="{Binding Url}"
Click="StoryButton_Click" FontFamily="Global User Interface"/>
</Grid>
</Grid>
</Grid>
</Grid>
</StackPanel>
</Border>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<Button Foreground="White" Content="Send Notification" Grid.Row="0" HorizontalAlignment="Stretch" Name="ToastButton" Click="ToastButton_Click" Margin="0,0,0,25.333"/>
</StackPanel>
</ScrollViewer>
</PivotItem>
<PivotItem x:Name="News" Header="news">
<WebView x:Name="MyWebView" NavigationCompleted="MyWebView_NavigationCompleted"/>
</PivotItem>
</Pivot>
</Grid>
</Page>

How do i solve this XAML error?

I'm getting that i havent closed the page, tried to close still gives me the error. I can't figure out what seems to be the problem, this probably is due to my inexperience with c# because i just started learning it begin this week.
see my code below and thanks for helping!
<Page
x:Class="DrawProg.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:DrawProg"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<common:LayoutAwarePage.Resources>
<Style x:Key="BaseStatusStyle" TargetType="TextBlock">
<Setter Property="FontFamily" Value="Segoe UI Semilight"/>
<Setter Property="FontSize" Value="14.667"/>
<Setter Property="Margin" Value="0,0,0,5"/>
</Style>
<Style x:Key="StatusStyle" BasedOn="{StaticResource BaseStatusStyle}" TargetType="TextBlock">
<Setter Property="Foreground" Value="Green"/>
</Style>
<Style x:Key="ErrorStyle" BasedOn="{StaticResource BaseStatusStyle}" TargetType="TextBlock">
<Setter Property="Foreground" Value="Blue"/>
</Style>
</common:LayoutAwarePage.Resources>
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<Grid x:Name="ContentRoot" Background="{StaticResource ApplicationPageBackgroundThemeBrush}" Margin="100,20,100,20">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- Header -->
<StackPanel Orientation="Horizontal" Grid.Row="0">
<Image x:Name="WindowsLogo" Stretch="None" Source="Assets/windows-sdk.png" AutomationProperties.Name="Windows Logo" HorizontalAlignment="Left" Grid.Column="0"/>
<TextBlock Text="Windows SDK Samples" VerticalAlignment="Bottom" Style="{StaticResource TitleTextStyle}" TextWrapping="Wrap" Grid.Column="1"/>
</StackPanel>
<ScrollViewer x:Name="MainScrollViewer" Grid.Row="1" ZoomMode="Disabled" IsTabStop="False" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" Padding="0,0,0,20" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock x:Name="FeatureName" Grid.Row="0" Text="Add Sample Title Here" Style="{StaticResource HeaderTextStyle}" TextWrapping="Wrap"/>
<!-- Content -->
<Grid Grid.Row="1">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Text="Input" Style="{StaticResource H2Style}"/>
<TextBlock x:Name="ScenarioListLabel" Text="Select Scenario:" Grid.Row="1" Style="{StaticResource SubheaderTextStyle}" Margin="0,5,0,0" />
<ListBox x:Name="Scenarios" Margin="0,0,20,0" Grid.Row="2" AutomationProperties.Name="Scenarios" HorizontalAlignment="Left"
VerticalAlignment="Top" ScrollViewer.HorizontalScrollBarVisibility="Auto"
AutomationProperties.LabeledBy="{Binding ElementName=ScenarioListLabel}" MaxHeight="125" Padding="0,0,27,0">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<TextBlock x:Name="DescriptionText" Margin="0,5,0,0" Text="Description:" Style="{StaticResource SubheaderTextStyle}" Grid.Row="1" Grid.Column="1"/>
<!-- Input Scenarios -->
<UserControl x:Name="InputSection" Margin="0,5,0,0" IsTabStop="False" Grid.Row="2" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Top"/>
<!-- Output section -->
<TextBlock Text="Output" Grid.Row="5" Margin="0,25,0,20" Style="{StaticResource H2Style}" Grid.ColumnSpan="2"/>
<TextBlock x:Name="StatusBlock" Grid.Row="6" Margin="0,0,0,5" Grid.ColumnSpan="2" Visibility="Collapsed"/>
<!-- Output Scenarios -->
<UserControl x:Name="OutputSection" Grid.Row="7" Grid.ColumnSpan="2" BorderThickness="0"/>
</Grid>
</Grid>
</Grid>
</ScrollViewer>
<!-- Footer -->
<Grid x:Name="Footer" Grid.Row="3" Margin="0,10,0,10" VerticalAlignment="Bottom" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Image Grid.Row="0" Source="Assets/microsoft-sdk.png" AutomationProperties.Name="Microsoft Logo" Stretch="None" HorizontalAlignment="Left"/>
<TextBlock Style="{StaticResource FooterStyle}" Text="© Microsoft Corporation. All rights reserved." TextWrapping="Wrap" Grid.Row="1" HorizontalAlignment="Left"/>
<StackPanel x:Name="FooterPanel" Orientation="Horizontal" Grid.Row="1" Grid.Column="1" HorizontalAlignment="Right">
<HyperlinkButton Content="Terms of use" Tag="http://www.microsoft.com/About/Legal/EN/US/IntellectualProperty/Copyright/default.aspx"
Click="Footer_Click" FontSize="12" Style="{StaticResource HyperlinkStyle}"/>
<TextBlock Text="|" Style="{StaticResource SeparatorStyle}" VerticalAlignment="Center"/>
<HyperlinkButton Content="Trademarks" Tag="http://www.microsoft.com/About/Legal/EN/US/IntellectualProperty/Trademarks/EN-US.aspx"
Click="Footer_Click" FontSize="12" Style="{StaticResource HyperlinkStyle}"/>
<TextBlock Text="|" Style="{StaticResource SeparatorStyle}" VerticalAlignment="Center"/>
<HyperlinkButton Content="Privacy Statement" Tag="http://privacy.microsoft.com" Click="Footer_Click" FontSize="12" Style="{StaticResource HyperlinkStyle}"/>
</StackPanel>
</Grid>
</Grid>
<VisualStateManager.VisualStateGroups>
<!-- Visual states reflect the application's window size -->
<VisualStateGroup>
<VisualState x:Name="DefaultLayout">
<Storyboard>
</Storyboard>
</VisualState>
<VisualState x:Name="Below768Layout">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)" Storyboard.TargetName="ContentRoot">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Thickness>20,20,20,20</Thickness>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.HorizontalAlignment)" Storyboard.TargetName="FooterPanel">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<HorizontalAlignment>Left</HorizontalAlignment>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</common:LayoutAwarePage>
Try replacing the final tag with
</Page>