0
魔女を見つける方法はありますかItem
番号はGridView
のポインタの下にありますか?私はマウスの下の項目に関する短い情報をクリックすることなく項目を選択することなく表示するのが好きです。UWP:GridViewを取得するにはどうすればいいですか?
魔女を見つける方法はありますかItem
番号はGridView
のポインタの下にありますか?私はマウスの下の項目に関する短い情報をクリックすることなく項目を選択することなく表示するのが好きです。UWP:GridViewを取得するにはどうすればいいですか?
ItemTemplate
のルート要素にはPointerEntered
とPointerExited
イベントを処理できます。
XAML:
<GridView>
<x:Int32>1</x:Int32>
<x:Int32>2</x:Int32>
<x:Int32>3</x:Int32>
<GridView.ItemContainerStyle>
<Style TargetType="GridViewItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Stretch" />
</Style>
</GridView.ItemContainerStyle>
<GridView.ItemTemplate>
<DataTemplate>
<Grid PointerEntered="TextBlock_PointerEntered"
PointerExited="TextBlock_PointerExited"
Background="Transparent">
<TextBlock Text="{Binding}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Grid>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
<TextBlock x:Name="tb" />
コード:
private void TextBlock_PointerEntered(object sender, PointerRoutedEventArgs e)
{
Panel root = sender as Panel;
var dataObject = root.DataContext;
tb.Text = dataObject.ToString(); //displays the currently pointed number in "tb"
}
private void TextBlock_PointerExited(object sender, PointerRoutedEventArgs e)
{
tb.Text = string.Empty;
}
OMG!シンプルだが効果的。私は、** 'DataTemplate'の中で' PointerEntered'のようなイベントを使うことはできないと思いました。そして、あなたが与えたあなたの例は、もっとはっきりしていないことがあります。ありがとう! – Weissu