弹出窗口的操作增量-XAML Windows 8 [英] manipulationdelta for popup window - XAML Windows 8

查看:113
本文介绍了弹出窗口的操作增量-XAML Windows 8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在屏幕上放置浮动弹出窗口.我希望用户能够将该弹出窗口移动到屏幕上的任意位置.

I am trying to put floating popup windows on screen. I want user to be able to move that popup window anywhere on the screen.

所以我正在使用:

<Popup x:Name="myPopup" Grid.Row="0" Grid.RowSpan="2" Margin="0, 0, 0, 0"  ManipulationMode="All" ManipulationDelta="PopupManipulationDelta" IsLightDismissEnabled="False" Visibility="Collapsed" IsOpen="false">

后面的代码:

private void PopupManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
    {
        var ct = (CompositeTransform)addShapesPopup.RenderTransform;
        ct.TranslateX += e.Delta.Translation.X;
        ct.TranslateY += e.Delta.Translation.Y;               
        UpdateLayout();
    }

但是这不起作用.函数PopupManipulationDelta甚至没有被调用.

But this is not working. The function PopupManipulationDelta is not even getting called.

我尝试在矩形,椭圆形等形状上使用相同的逻辑,并且在那里工作得很好.

I tried using same logic on shapes like rectangle, ellipse and it works fine there.

能否请您帮我了解为什么它不能与弹出窗口一起使用?

Can you please help me understand why it's not working with popup?

谢谢.

推荐答案

我认为Popup没有任何视觉表示,因此它无法响应点击测试,因此无法响应操作事件.只需在其中放置一些控件,然后使其对输入事件做出响应即可.如果您不希望它显示,可以将它与Background="Transparent"一起作为Grid.

I believe a Popup does not have any visual representation, so it can't respond to hit testing and thus to manipulation events. Simply put some control inside of it and have that respond to the input events. It can be a Grid with Background="Transparent" if you don't want it to be visible.

这篇关于弹出窗口的操作增量-XAML Windows 8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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