操作在Grid中不起作用 [英] Manipulation Not working in Grid

查看:122
本文介绍了操作在Grid中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带网格控件的非常简单的页面,但操作事件不会触发。有什么问题,网格中没有事件触发器?谢谢。

I have a very simple page with a grid control , but the Manipulation event does not fire. What's wrong there is no event trigger in the grid? Thanks.

XAML代码:

<Page
    x:Class="App2.BlankPage3"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App2">
 
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Grid  ManipulationMode="TranslateX, System" ManipulationStarting="Grid_ManipulationStarting" ManipulationCompleted="Grid_ManipulationCompleted">


        </Grid>
    </Grid>
</Page>

编码是:

private void Grid_ManipulationStarting(object sender, ManipulationStartingRoutedEventArgs e)
{
}
 
private void Grid_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
{
    System.Diagnostics.Debug.WriteLine($"{e.Cumulative.Translation.X}");
}

Jobria

推荐答案

你好Jobria,

Hi Jobria,

欢迎来到开发通用Windows应用程序论坛! 

请阅读粘贴帖子,特别是  引导
发布:主题行标签
 &absp; Windows 10的已知问题SDK和工具

Please read the sticky posts, especially the Guide to posting: subject line tags and Known Issues for Windows 10 SDK and Tools.

似乎某些Panel控件没有设置后台或Fill属性会导致某些事件无效。

It seems some Panel control that without setting the Background or the Fill property that will make some event can not work.

确定UI中是否以及在何处对鼠标,触摸和手写笔输入可见元素称为命中测试。对于触摸操作以及触摸操作后果的特定于交互或操纵事件,元素必须是
hit-test可见才能成为事件源并触发与之关联的事件行动。否则,操作会将元素传递给可视树中可与该输入交互的任何基础元素或父元素。

有关详细信息,请参阅
命中测试输入事件

For more info, see Hit testing and input events.

因此我们应该能够设置Grid的Background属性,可以触发ManipulationMode事件和ManipulationStarting事件。

So we should be able to set the Background property of the Grid that the ManipulationMode event and ManipulationStarting event can be fired.

例如:

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Grid Background="Transparent"  ManipulationMode="TranslateX, System" ManipulationStarting="Grid_ManipulationStarting" ManipulationCompleted="Grid_ManipulationCompleted">
    </Grid>
</Grid>

最好的问候,

Jayden Gu

Jayden Gu


这篇关于操作在Grid中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆