manipulationdelta for popup window - XAML Windows 8

房东的猫 提交于 2019-12-12 22:33:01

问题


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.

And so I am using:

<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">

code behind:

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();
    }

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?

Thank you.


回答1:


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.



来源:https://stackoverflow.com/questions/15669536/manipulationdelta-for-popup-window-xaml-windows-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!