私は既にSimulating a mousehover effect on a fontIcon in uwpをチェックしています。しかし、私は別の "ちらつき"問題に直面しています。UWP - グリッド行のマウスオーバーをシミュレートするPointerEntered/PointerExited
私はPivotItemコントロールの子であるScrollViewerの中にグリッドを持っています。グリッドは最初は空であり、その後にプログラムで入力されます。
<PivotItem>
<ScrollViewer x:Name="MyScrollBar" >
<Grid Name="MyGrid">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
</Grid>
</ScrollViewer>
</PivotItem>
各列に3つのTextBlockがそれぞれ格納されます。 私の目標は、1つの行(1つのTextBlockではなく)にカーソルを置いたときにフライアウトに詳細を表示することです。これを達成するため、ColumnSpanが3である透明なRectangleを各行ごとに定義し、各行の最後の子として追加します。ここで
Rectangle rect = new Rectangle();
rect.Opacity = 0;
rect.SetValue(Grid.RowProperty, r);
rect.SetValue(Grid.ColumnSpanProperty, 3);
Flyout fl = new Flyout();
Grid flGrid = new Grid();
TextBlock flTb1 = new TextBlock();
flTb1.Text = details.Name;
flGrid.Children.Add(flTb1);
fl.Content = flGrid;
rect.SetValue(FlyoutBase.AttachedFlyoutProperty, fl);
rect.PointerEntered += Rect_PointerEntered;
rect.PointerExited += Rect_PointerExited;
rect.Margin = new Thickness(2);
PointerEnteredとPointerExitedイベントハンドラ:次のように私はそれにフライアウトを与える
private void Rect_PointerEntered(object sender, PointerRoutedEventArgs e)
{
((Flyout)(((Rectangle)sender).GetValue(FlyoutBase.AttachedFlyoutProperty))).ShowAt((Rectangle)sender);
}
private void Rect_PointerExited(object sender, PointerRoutedEventArgs e)
{
((Flyout)(((Rectangle)sender).GetValue(FlyoutBase.AttachedFlyoutProperty))).Hide();
}
ポインタがグリッド行のヒットゾーンに入ると、突然、フライアウトは と消滅するが表示されます。そして、同じ行であってもポインタが移動するたびに(同じ行にポインタを移動するとフライアウトが消えないようにします)。結果はちらつきフライアウトです。 PointerEntered/PointerExitedイベントは、どちらのポイントでも発生しているように見えます。
- はfalseにPointerEntered.Handled PointerEnteredのみ(私はこれがベストプラクティスではありませんけど、私が試した)
- セットハンドル(私は多分、他のコントロールと思った:私はすでに試してみました何
グリッド内の矩形(S)ポインタが同じ以上であるときに認識する/他の行の動作)
- のみ
- 「ホバー」ストアドPointerMovedハンドルおよび「ホバリング」に影響し
- 私が覚えていない多くの試みは、常に同じちらつきの結果を得ています。
誰かが正しい方向に向いていますか?前もって感謝します!