更新 1 : https://bitbucket.org/vmrocha/gridview-issue/src
UPDATE 2:マウスを使用した選択は機能しますが、機能しない選択はタッチを使用したものです。
以下のコードを書いたのですが、横スクロールを「無効」にするとGridViewの選択が効かなくなります。
XAML:
<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:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Page.Resources>
<ItemsPanelTemplate x:Key="itemsPanelTemplate">
<StackPanel />
</ItemsPanelTemplate>
<DataTemplate x:Key="dataTemplate">
<Grid Width="100" Height="100">
<TextBlock Text="{Binding}" />
</Grid>
</DataTemplate>
<Style TargetType="GridView">
<Setter Property="SelectionMode" Value="Multiple" />
<Setter Property="IsItemClickEnabled" Value="True" />
</Style>
</Page.Resources>
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<ScrollViewer HorizontalScrollMode="Auto"
VerticalScrollMode="Disabled">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<!--The selection here does not work-->
<GridView x:Name="gridView1" ItemsSource="{Binding Items1}"
ItemsPanel="{StaticResource itemsPanelTemplate}"
ItemTemplate="{StaticResource dataTemplate}"
ScrollViewer.HorizontalScrollMode="Disabled">
</GridView>
<GridView x:Name="gridView2" ItemsSource="{Binding Items2}" Grid.Column="1"
ItemsPanel="{StaticResource itemsPanelTemplate}"
ItemTemplate="{StaticResource dataTemplate}">
</GridView>
</Grid>
</ScrollViewer>
</Grid>
C# コード:
public MainPage()
{
this.InitializeComponent();
this.Items1 = new ObservableCollection<string>();
this.Items2 = new ObservableCollection<string>();
this.PopulateItems();
this.DataContext = this;
}
private void PopulateItems()
{
this.Items1.Add("String 1");
this.Items1.Add("String 1");
this.Items1.Add("String 1");
this.Items1.Add("String 1");
this.Items1.Add("String 1");
this.Items1.Add("String 1");
this.Items1.Add("String 1");
this.Items2.Add("String 2");
this.Items2.Add("String 2");
this.Items2.Add("String 2");
this.Items2.Add("String 2");
this.Items2.Add("String 2");
this.Items2.Add("String 2");
this.Items2.Add("String 2");
}
ScrollViewer.HorizontalScrollMode="Disabled" という行を削除すると、選択が再び機能し始めます。
何か案は?