How do I change Textbox Header color on hover? - xaml

I have the following:
<TextBox HorizontalAlignment="Stretch" VerticalAlignment="Stretch" FontSize="12" Header="Name" >
<TextBox.HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" Foreground="Red" />
</DataTemplate>
</TextBox.HeaderTemplate>
Is there a way through the DataTemplate or Xaml behaviors to change the Foreground?

You can use XamlBehaviors.
Add Nuget Microsoft.Xaml.Behaviors.Uwp.Managed and references in Xaml.
xmlns:Core="using:Microsoft.Xaml.Interactions.Core"
xmlns:Interactivity="using:Microsoft.Xaml.Interactivity"
Handle PointerEntered and PointerExited event on TextBlock.
<TextBox HorizontalAlignment="Stretch" VerticalAlignment="Stretch" FontSize="12" Header="Name" >
<TextBox.HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" Foreground="Red">
<Interactivity:Interaction.Behaviors>
<Core:EventTriggerBehavior EventName="PointerEntered">
<Core:ChangePropertyAction PropertyName="Foreground">
<Core:ChangePropertyAction.Value>
<SolidColorBrush Color="Blue" />
</Core:ChangePropertyAction.Value>
</Core:ChangePropertyAction>
</Core:EventTriggerBehavior>
<Core:EventTriggerBehavior EventName="PointerExited">
<Core:ChangePropertyAction PropertyName="Foreground">
<Core:ChangePropertyAction.Value>
<SolidColorBrush Color="Red" />
</Core:ChangePropertyAction.Value>
</Core:ChangePropertyAction>
</Core:EventTriggerBehavior>
</Interactivity:Interaction.Behaviors>
</TextBlock>
</DataTemplate>
</TextBox.HeaderTemplate>
</TextBox>

Related

UWP hamburger menu top and bottom

How can I make Hamburger menu on top and on bottom in XAML - UWP?
This is my SplitView.Pane
<SplitView.Pane>
<Grid>
<Border Background="{StaticResource PanelBackground}"/>
<ListView x:Name="navMenuList"
SelectionMode="Single"
IsItemClickEnabled="True"
Margin="0,0,0,0" ItemsSource="{Binding Menus}">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Width="240" HorizontalAlignment="Left" Height="48">
<SymbolIcon Margin="2,0,0,0" Symbol="{Binding Symbol}" Foreground="White"/>
<TextBlock Margin="24,0,0,0" Text="{Binding Text}" VerticalAlignment="Center" Foreground="White"/>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
<interactivity:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="ItemClick">
<core:InvokeCommandAction Command="{Binding Path=MenuCommand}" CommandParameter="{Binding Target}"/>
</core:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
</ListView>
</Grid>
</SplitView.Pane>
Is a good way to duplicite whole ListView with another binding?
// EDIT
I need something like this (but with more menu items :)):
<SplitView x:Name"RootSplitView">
</SplitView>
<ToggleButton x:Name="TogglePaneButton"
TabIndex="1"
Style="{StaticResource SplitViewTogglePaneButtonStyle}"
IsChecked="{Binding IsPaneOpen, ElementName=RootSplitView, Mode=TwoWay}"
Unchecked="TogglePaneButton_Checked"
AutomationProperties.Name="Menu"
ToolTipService.ToolTip="Menu" Background="#E53DAFBD" Foreground="#FFF9EAEA" />
You can try this code
<SplitView.Pane>
<Grid>
<StackPanel>
<ToggleButton x:Name="HamburgerButton" FontFamily="Segoe MDL2 Assets" Content=""
Width="50" Height="50" Background="Transparent" Tapped="HamburgerButton_Tapped" Foreground="White"
FontSize="16" FontWeight="Bold" Style="{StaticResource HamburgerToggleButtonStyle}" />
<RadioButton Content="Top 1" x:Name="btn1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" IsChecked="False" Foreground="White" GroupName="HamMenu"/>
<RadioButton Content="Top 2" x:Name="btn2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" IsChecked="True" Foreground="White" GroupName="HamMenu"/>
<RadioButton Content="Top 3" x:Name="btn3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" IsChecked="False" Foreground="White" GroupName="HamMenu"/>
</StackPanel>
<StackPanel VerticalAlignment="Bottom">
<RadioButton Content="Bottom 1" x:Name="btn4" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" IsChecked="False" Foreground="White" GroupName="HamMenu"/>
<RadioButton Content="Bottom 2" x:Name="btn5" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" IsChecked="False" Foreground="White" GroupName="HamMenu"/>
</StackPanel>
</Grid>
</SplitView.Pane>

Set ContentDialog to show on bottom of page in UWP

I have several ContentDialogs in a RelativeLayout and want them to appear or have the the vertical alignment to "bottom". But it seems that no matter what I try the dialogs always appear on the top of the screen.
This is how they look now
Any ideas?
Here is a xaml code snippet:
<RelativePanel Height="{Binding ActualHeight, ElementName=Page}" >
<ContentDialog x:Name="EntrepriseDialog"
VerticalAlignment="Bottom"
Title="Vælg entreprise"
PrimaryButtonText=""
IsPrimaryButtonEnabled="{Binding IsChecked, ElementName=checkBoxAgree, Mode=OneWay}"
MaxWidth="{Binding ActualWidth, ElementName=pageRoot}" Grid.ColumnSpan="2" Margin="30,194,-71,-194">
<ListView Name="ListEntreprises" VerticalAlignment="Bottom" SelectionChanged="ListEntreprises_SelectionChanged">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
<Setter Property="Margin" Value="0,0,0,1"></Setter>
<Setter Property="Background" Value="Transparent"></Setter>
<Setter Property="Padding" Value="5"></Setter>
</Style>
</ListView.ItemContainerStyle>
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<StackPanel>
<TextBlock>
<Run FontSize="15" Text="{Binding Name}"/>
</TextBlock>
<TextBlock Visibility="Collapsed">
<Run Text="{Binding Id}"/>
</TextBlock>
</StackPanel>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</ContentDialog>
<ContentDialog x:Name="SaveChooseDialog"
VerticalAlignment="Bottom"
Title=""
PrimaryButtonText=""
IsPrimaryButtonEnabled="{Binding IsChecked, ElementName=checkBoxAgree, Mode=OneWay}"
MaxWidth="{Binding ActualWidth, ElementName=pageRoot}" Grid.ColumnSpan="2" Margin="30,148,-71,-148">
<ListBox Name="ListBoxSaveMode" SelectionChanged="ListBoxSaveMode_SelectionChanged">
<ListBoxItem>
<TextBlock Name="TxtLocally" Text="Gem lokalt"/>
</ListBoxItem>
<ListBoxItem>
<TextBlock Name="TxtServer" Text="Gem på server"/>
</ListBoxItem>
<ListBoxItem>
<TextBlock Name="TxtCancel" Text="Annullér"/>
</ListBoxItem>
</ListBox>
</ContentDialog>
<ContentDialog x:Name="AddPictureDialog"
VerticalAlignment="Bottom"
Title=""
PrimaryButtonText=""
IsPrimaryButtonEnabled="{Binding IsChecked, ElementName=checkBoxAgree, Mode=OneWay}"
MaxWidth="{Binding ActualWidth, ElementName=pageRoot}" Grid.ColumnSpan="2" Margin="30,142,-71,-142">
<ListBox Name="ListBoxAddPicture" SelectionChanged="ListBoxAddPicture_SelectionChanged">
<ListBoxItem>
<TextBlock Name="TxtFromCamera" Text="Tag et nyt"/>
</ListBoxItem>
<ListBoxItem>
<TextBlock Name="TxtFromStorage" Text="Vælg fra kamerarulle"/>
</ListBoxItem>
</ListBox>
</ContentDialog>
</RelativePanel>
EDIT: XAML for entire Page
<Page
Name="Page"
x:Class="...Pages.Documentation.DocumentationCreatePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:...Pages.Documentation"
xmlns:userControl="using:...Pages.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="#8FBC3E">
<Grid>
<Grid.Background>
<ImageBrush Stretch="UniformToFill" ImageSource="/Assets/Images/mainBg.png" />
</Grid.Background>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel>
<Grid Height="40" Background="#8FBC3E" >
<StackPanel Orientation="Horizontal">
<Button Name="BtnBack" Click="BtnBack_Click" Margin="20 0 20 0" >
<Button.Template>
<ControlTemplate>
<TextBlock FontSize="20" Foreground="White" FontFamily="Segoe MDL2 Assets" Text=""></TextBlock>
</ControlTemplate>
</Button.Template>
</Button>
<TextBlock Name="TxtTitle" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White" FontSize="18"/>
</StackPanel>
</Grid>
<userControl:SyncDataControl></userControl:SyncDataControl>
</StackPanel>
<Grid Grid.Row="1" Name="StackPanel">
<ProgressRing Name="SaveProgressRing" IsActive="False" Foreground="#8FBC3E" Width="40" Height="40" Margin="152,239,87,321" />
<StackPanel Grid.ColumnSpan="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
<ListView Name="ListViewDocumentationItems" ScrollViewer.VerticalScrollMode="Disabled" SelectionChanged="ListViewDocumentationItems_SelectionChanged">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="Height" Value="80"></Setter>
<Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
<Setter Property="VerticalContentAlignment" Value="Center"></Setter>
<Setter Property="Margin" Value="0,0,0,1"></Setter>
<Setter Property="Background" Value="White"></Setter>
</Style>
</ListView.ItemContainerStyle>
<ListView.ItemTemplate>
<DataTemplate>
<Grid VerticalAlignment="Center">
<StackPanel Padding="0 0 10 0" Orientation="Horizontal" >
<Image Source="{Binding ImageSource}" VerticalAlignment="Center" Height="40" Margin="5 0 5 0"></Image>
<TextBlock Foreground="Black" HorizontalAlignment="Left" VerticalAlignment="Center">
<Run FontWeight="Bold" FontSize="20" Text="{Binding Name}"/>
</TextBlock>
</StackPanel>
<Grid HorizontalAlignment="Right">
<StackPanel Orientation="Horizontal">
<TextBlock Foreground="Black" VerticalAlignment="Center" Padding="0 0 20 0">
<Run FontSize="15" Text="{Binding Count}"/>
</TextBlock>
<Image Width="15" Height="15" VerticalAlignment="Center" Source="/Assets/Images/rightarrow.png" />
</StackPanel>
</Grid>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<TextBlock Name="TxtDocDesc" TextWrapping="Wrap" Foreground="Gray" Height="53" />
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<StackPanel Name="PicturePanel" Orientation="Horizontal" Margin="15 0 15 0" />
</ScrollViewer>
</StackPanel>
<Button Name="BtnSave" Grid.Row="2" VerticalAlignment="Bottom" FontSize="25" Click="BtnSave_Click" Background="#8FBC3E" Foreground="White" Height="60" Content="Gem" HorizontalAlignment="Stretch" Margin="5 5 5 5"/>
<RelativePanel VerticalAlignment="Stretch" >
<ContentDialog x:Name="EntrepriseDialog" VerticalContentAlignment="Bottom"
RelativePanel.AlignBottomWithPanel="True"
Title="Vælg entreprise"
PrimaryButtonText=""
IsPrimaryButtonEnabled="{Binding IsChecked, ElementName=checkBoxAgree, Mode=OneWay}"
MaxWidth="{Binding ActualWidth, ElementName=pageRoot}" >
<ListView Name="ListEntreprises" VerticalAlignment="Bottom" SelectionChanged="ListEntreprises_SelectionChanged">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
<Setter Property="Margin" Value="0,0,0,1"></Setter>
<Setter Property="Background" Value="Transparent"></Setter>
<Setter Property="Padding" Value="5"></Setter>
</Style>
</ListView.ItemContainerStyle>
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<StackPanel>
<TextBlock>
<Run FontSize="15" Text="{Binding Name}"/>
</TextBlock>
<TextBlock Visibility="Collapsed">
<Run Text="{Binding Id}"/>
</TextBlock>
</StackPanel>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</ContentDialog>
<ContentDialog x:Name="SaveChooseDialog"
RelativePanel.AlignBottomWithPanel="True"
Title=""
PrimaryButtonText=""
IsPrimaryButtonEnabled="{Binding IsChecked, ElementName=checkBoxAgree, Mode=OneWay}"
MaxWidth="{Binding ActualWidth, ElementName=pageRoot}">
<ListBox Name="ListBoxSaveMode" SelectionChanged="ListBoxSaveMode_SelectionChanged">
<ListBoxItem>
<TextBlock Name="TxtLocally" Text="Gem lokalt"/>
</ListBoxItem>
<ListBoxItem>
<TextBlock Name="TxtServer" Text="Gem på server"/>
</ListBoxItem>
<ListBoxItem>
<TextBlock Name="TxtCancel" Text="Annullér"/>
</ListBoxItem>
</ListBox>
</ContentDialog>
<ContentDialog x:Name="AddPictureDialog"
Title=""
PrimaryButtonText=""
IsPrimaryButtonEnabled="{Binding IsChecked, ElementName=checkBoxAgree, Mode=OneWay}"
MaxWidth="{Binding ActualWidth, ElementName=pageRoot}" >
<ListBox Name="ListBoxAddPicture" SelectionChanged="ListBoxAddPicture_SelectionChanged">
<ListBoxItem>
<TextBlock Name="TxtFromCamera" Text="Tag et nyt"/>
</ListBoxItem>
<ListBoxItem>
<TextBlock Name="TxtFromStorage" Text="Vælg fra kamerarulle"/>
</ListBoxItem>
</ListBox>
</ContentDialog>
<ContentDialog x:Name="DialogDownloadProgress"
VerticalAlignment="Stretch"
Title=""
MaxWidth="{Binding ActualWidth, ElementName=pageRoot}">
<StackPanel Padding="0,50">
<TextBlock Name="ProgressTitle" Text="Test test" HorizontalAlignment="Center" Padding="0 0 0 20"/>
<ProgressBar x:Name="ProgressBarDownload" HorizontalAlignment="Stretch" IsEnabled="True"></ProgressBar>
</StackPanel>
</ContentDialog>
</RelativePanel>
</Grid>
</Grid>
It seems the positioning of ContentDialog instances is not in the hands of the developer, at least not without custom versions of it. Afaik the OS will decide where to place the dialog for you.
See here for more information:
http://www.reflectionit.nl/blog/2015/windows-10-xaml-tips-messagedialog-and-contentdialog
So if positioning of the dialog is critical then you might have to create a custom control.

Execute command from DataTemplate

I have the following code:
<StackPanel Orientation="Vertical">
<GridView
Background="Azure"
x:Name="ContactList"
ItemsSource="{Binding Path=Users}"
SelectedItem="{Binding SelectedUser, Mode=TwoWay}">
<interactivity:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="SelectionChanged">
<core:InvokeCommandAction
Command="{Binding MyCommandOnTheViewModel, Mode=OneWay}"/>
</core:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
<GridView.ItemTemplate>
<DataTemplate>
<Border Width="300" Height="Auto" BorderThickness="1">
<StackPanel Orientation="Vertical">
<TextBlock HorizontalAlignment="Left">
<Run FontWeight="Bold" Text="{Binding Name}" />
<Run Text="{Binding Age}" />
</TextBlock>
<StackPanel Orientation="Horizontal">
<Button Content="Button1" HorizontalAlignment="Left"></Button>
<Button Content="Button2" HorizontalAlignment="Right"></Button>
</StackPanel>
</StackPanel>
</Border>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
</StackPanel>
At this point, the Command: MyCommandOnTheViewModel gets executed when I click on an item in the list. As you can see I also have a StackPanel containing two buttons. How Can I Bind two separate Commands to each button?
I´ve been trying to give my buttons names thinking that I could somehow do something like:
<interactivity:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="SelectionChanged" ELEMENTNAME="MyButtonsName">
<core:InvokeCommandAction
Command="{Binding MyCommandOnTheViewModel, Mode=OneWay}"/>
</core:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
But there does not seem to work like that.
Any tips appreciated!
This is what worked for me:
<Button Content="MyButton"
Command ="{Binding ElementName=ContactList,Path=DataContext.MyCommand}"></Button>
Thanks you for all help #Utsav
You can give Command property to each button. In that way you can easily bind two seperate commands in viewmodel with the two buttons, on click event.
See the code below.
<StackPanel Orientation="Vertical">
<GridView
Background="Azure"
x:Name="ContactList"
ItemsSource="{Binding Path=Users}"
SelectedItem="{Binding SelectedUser, Mode=TwoWay}">
<interactivity:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="SelectionChanged">
<core:InvokeCommandAction
Command="{Binding MyCommandOnTheViewModel, Mode=OneWay}"/>
</core:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
<GridView.ItemTemplate>
<DataTemplate>
<Border Width="300" Height="Auto" BorderThickness="1">
<StackPanel Orientation="Vertical">
<TextBlock HorizontalAlignment="Left">
<Run FontWeight="Bold" Text="{Binding Name}" />
<Run Text="{Binding Age}" />
</TextBlock>
<StackPanel Orientation="Horizontal">
<Button Content="Button1" HorizontalAlignment="Left" Command="{Binding CommandLeftBtn}"></Button>
<Button Content="Button2" HorizontalAlignment="Right" Command="{Binding CommandRightBtn}"></Button>
</StackPanel>
</StackPanel>
</Border>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
</StackPanel>

StackPanel Orientation stops page load

First to explain what I am doing here, I want to create a page that list a large number of grouped objects. Selecting an object binds that information to a display on the left. Everything works fine till I change the MainStack Orientation to Horizontal. Once that is changed the page no longer loads. No errors are thrown. When stepping through the process the code behind steps through as it should.
I know its the XAML but am baffled by the cause. It works fine under two circumstances.
If I drop the mainstack stack panel and instead make the display group the header of the GridView it works.
If I put the MainStack orientation to Vertical it loads fine.
Here is the code that does not load:
<StackPanel Name="MainStack" Orientation="Horizontal" Grid.Row="2" >
<StackPanel Name="Stack" Width="480" >
<TextBlock Text="{Binding Nname}" Margin="0,0,0,20" Style="{StaticResource SubheaderTextBlockStyle}" MaxHeight="60"/>
<TextBlock Text="{Binding Nset}" Margin="0,0,0,20" Style="{StaticResource SubheaderTextBlockStyle}" MaxHeight="60"/>
<Image Source="{Binding url}" Height="Auto" Margin="0,0,102,55" Stretch="UniformToFill" AutomationProperties.Name="{Binding Title}"/>
<ScrollViewer Margin="0,0,0,0" MaxHeight="200">
<TextBlock Text="{Binding Nruling}" Margin="0,0,0,0" Style="{StaticResource BodyTextBlockStyle}"/>
</ScrollViewer>
</StackPanel>
<SemanticZoom x:Name="semanticZoom" Width="Auto" >
<SemanticZoom.ZoomedOutView>
<GridView Foreground="White"
ScrollViewer.IsHorizontalScrollChainingEnabled="False">
<GridView.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Group.Key}"
FontFamily="Segoe UI" FontWeight="Light" FontSize="24" />
</DataTemplate>
</GridView.ItemTemplate>
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<ItemsWrapGrid ItemWidth="100" ItemHeight="100" MaximumRowsOrColumns="4"/>
</ItemsPanelTemplate>
</GridView.ItemsPanel>
<GridView.ItemContainerStyle>
<Style TargetType="GridViewItem">
<Setter Property="Margin" Value="4" />
<Setter Property="Padding" Value="10" />
<Setter Property="Background" Value="#FF25A1DB" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="VerticalContentAlignment" Value="Bottom" />
</Style>
</GridView.ItemContainerStyle>
</GridView>
</SemanticZoom.ZoomedOutView>
<SemanticZoom.ZoomedInView>
<GridView
x:Name="itemGridView"
AutomationProperties.AutomationId="ItemGridView"
AutomationProperties.Name="Items In Group"
TabIndex="1"
Padding="120,126,120,50"
ItemsSource="{Binding Source={StaticResource itemsViewSource}}"
SelectionMode="Single"
ScrollViewer.IsHorizontalScrollChainingEnabled="False" SelectionChanged="itemGridView_SelectionChanged">
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<ItemsWrapGrid MaximumRowsOrColumns="8" GroupHeaderPlacement="Top" />
</ItemsPanelTemplate>
</GridView.ItemsPanel>
<GridView.ItemTemplate>
<DataTemplate>
<Grid Height="110" Width="480" Margin="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border Background="{ThemeResource ListViewItemPlaceholderBackgroundThemeBrush}" Width="110" Height="110">
<Image Source="{Binding url}" Stretch="UniformToFill" AutomationProperties.Name="{Binding Nname}"/>
</Border>
<StackPanel Grid.Column="1" VerticalAlignment="Top" Margin="10,0,0,0">
<TextBlock Text="{Binding Nname}" Style="{StaticResource TitleTextBlockStyle}" TextWrapping="NoWrap"/>
<TextBlock Text="{Binding Nset}" Style="{StaticResource CaptionTextBlockStyle}" TextWrapping="NoWrap"/>
<TextBlock Text="{Binding Nruling}" Style="{StaticResource BodyTextBlockStyle}" MaxHeight="60"/>
</StackPanel>
</Grid>
</DataTemplate>
</GridView.ItemTemplate>
<GridView.ItemContainerStyle>
<Style TargetType="FrameworkElement">
<Setter Property="Margin" Value="52,0,0,2"/>
</Style>
</GridView.ItemContainerStyle>
<GridView.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}" Margin="10">
<TextBlock Text='{Binding Key}' Foreground="{StaticResource ApplicationForegroundThemeBrush}" FontSize="25" Margin="5" />
</Grid>
</DataTemplate>
</GroupStyle.HeaderTemplate>
</GroupStyle>
</GridView.GroupStyle>
</GridView>
</SemanticZoom.ZoomedInView>
</SemanticZoom>
<!-- Horizontal scrolling grid -->
</StackPanel>

GridView scroll in Metro application doesn't work

I trying to build a winRT metro application that use a GridView. I get the GridView and it looks like I want it to do. But the horizontal scroll doesn't work. When I drag the content it move but when I release it, it will return to start.
Anyone that know why it doesn't work?
<Page
x:Class="WR.Levels"
IsTabStop="false"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Wordy"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:uc="using:Wordy.UserControls"
mc:Ignorable="d">
<UserControl.Resources>
<CollectionViewSource x:Name="cvsLevels" IsSourceGrouped="True"/>
<CollectionViewSource x:Name="cvsCategories" IsSourceGrouped="True" ItemsPath="Levels"/>
</UserControl.Resources>
<Canvas x:Name="innertialCanvas"
Grid.Row="1"
Background="#FF3D6E4F"
>
<uc:BG HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="84"/>
<RowDefinition Height="700"/>
</Grid.RowDefinitions>
<StackPanel Margin="20,20,0,0" Grid.Row="0" Orientation="Horizontal">
<Button x:Name="backButton" Style="{StaticResource BackButtonStyle}" Margin="10" VerticalAlignment="Center" >Back</Button>
<TextBlock Name="appName" Text="WR" FontSize="48" VerticalAlignment="Center" />
</StackPanel>
<GridView ItemsSource="{Binding Source={StaticResource cvsCategories}}" Margin="0,0,0,0"
IsItemClickEnabled="True" SelectionMode="None" MaxHeight="700" Grid.Row="1"
AutomationProperties.AutomationId="LevelsGrid">
<GridView.ItemTemplate>
<DataTemplate>
<StackPanel Width="150" Height="130" Margin="10" AutomationProperties.AutomationId="Level">
<StackPanel.Background>
<SolidColorBrush Color="White" Opacity="0.2" />
</StackPanel.Background>
<StackPanel Orientation="Horizontal" Margin="10">
<uc:Stars Height="50" Width="50" />
<uc:Stars Height="50" Width="50" />
</StackPanel>
<TextBlock Text="{Binding Name}" Margin="0,10,0,0" FontSize="24" HorizontalAlignment="Center"></TextBlock>
</StackPanel>
</DataTemplate>
</GridView.ItemTemplate>
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</GridView.ItemsPanel>
<GridView.GroupStyle>
<GroupStyle HidesIfEmpty="True">
<GroupStyle.HeaderTemplate>
<DataTemplate>
<Grid Margin="0">
<TextBlock Text='{Binding Name}'
Foreground="White" Margin="20"
Style="{StaticResource HeaderTextStyle}" AutomationProperties.AutomationId="LevelGroup"/>
</Grid>
</DataTemplate>
</GroupStyle.HeaderTemplate>
<GroupStyle.ContainerStyle>
<Style TargetType="GroupItem">
<Setter Property="Margin" Value="3,0"/>
</Style>
</GroupStyle.ContainerStyle>
<GroupStyle.Panel>
<ItemsPanelTemplate>
<VariableSizedWrapGrid/>
</ItemsPanelTemplate>
</GroupStyle.Panel>
</GroupStyle>
</GridView.GroupStyle>
</GridView>
</Grid>
</Canvas>
</Page>
When I removed the canvas tag it worked!