在winrt中操纵Evnts [英] Manipulation Evnts in winrt

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

问题描述

大家好,

                   我正在winrt xaml中创建自定义时间轴控件。最初它将显示带有年份的月份名称。但是如果用户尝试使用触摸来缩放它,那么我需要调整月份
的宽度。在特定宽度之后,几个月将分为几天,然后在几周之后,依此类推,直到特定结束。如果我使用translate transform,那么它只会像滚动查看器中的控件一样调整大小。我只需要调整宽度而不是高度而不是文本的大小。而且捏或缩放应该是现实的。 delta(scale,expansion,translation ...)中的值是什么以及如何将这些值用于此操作?

                   I am creating a custom timeline control in winrt xaml. Initially it will display the name of the months with year. But if user tries to zoom it using touch then I need to resize the months width. And after a specific width, then months will divide into days and then after weeks and so on till a specific end. If I use translate transform for that then it only resizes it like a control inside a scrollviewer. I need only to resize the width not the height and not the size of texts. And also the pinch or zoom should be realistic. What are the values in delta (scale, expansion, translation...) and how to use these values for this action?

Dinesh Rawat Sr.软件顾问Windows Phone-WinRT-Silverlight MCTS Silverlight

Dinesh Rawat Sr. Software Consultant Windows Phone-WinRT-Silverlight MCTS Silverlight

推荐答案

首先您需要了解这一点:

First you need to understand this:

private void setManipulationOnMyControl()
{
    //Set what all manipulations are you interested in, see ManipulationModes enum
    MyControl.ManipulationMode = ManipulationModes.Scale | ManipulationModes.TranslateRailsX;

    MyControl.ManipulationStarting += MyControl_ManipulationStarting;

    MyControl.ManipulationStarted += MyControl_ManipulationStarted;

    MyControl.ManipulationDelta += MyControl_ManipulationDelta;

    MyControl.ManipulationCompleted += MyControl_ManipulationCompleted;

    MyControl.ManipulationInertiaStarting += MyControl_ManipulationInertiaStarting;
}

private void MyControl_ManipulationStarting(object sender, ManipulationStartingRoutedEventArgs e)
{
    /*This gets called when Maipulation is about  to start; look into ManipulationStartingRoutedEventArgs 
        * for details of what you get; it is less common to use it*/
    e.Handled = true;
}

private void MyControl_ManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e)
{
    /*This gets called when Maipulation has started; look into ManipulationStartedRoutedEventArgs 
        * for details of what you get; it is less common to use it*/
    e.Handled = true;
}

private void MyControl_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
{
    /*This gets called at regular interval after Maipulation has started; look into ManipulationDeltaRoutedEventArgs 
        * for details of what you get; this will be used most of the times*/
    e.Handled = true;
}

private void MyControl_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
{
    /*This gets called after Maipulation has competed; look into ManipulationCompletedRoutedEventArgs 
        * for details of what you get; this will be used most of the times*/
    e.Handled = true;
}

private void MyControl_ManipulationInertiaStarting(object sender, ManipulationInertiaStartingRoutedEventArgs e)
{
    /* If you see scroll viewr in Touch mode, if user scrolls with some speed it kind keeps scrolling 
        * even when screen is not in touch contact that is inertia. It is keeps running on last velocity and some logic.
        * This gets called before manipulatioon completed if maanipulation mode was TranslateInertia, RotateInertia and/or ScaleInertia
        * look into ManipulationInertiaStartingRoutedEventArgs for details of what you get; it is less common to use it*/
    e.Handled = true;
}

现在我从你的描述中理解你需要缩放手势并增加宽度。为您的控件定义可视状态,您可以在其中定义每个项目的宽度,也可以是其他外观。在  ManipulationCompleted中,您希望根据比例因子等条件更改
Visual State。您可以使用ManipulationDelta显示一些动画或过渡状态以提供一些视觉反馈。

Now what I understand from your description your need Scale gesture and increase width. Define Visual States for your control where you will define Width of each item and may be other look and feels. In ManipulationCompleted you will like to change Visual State based on conditions like scale factor. You can use ManipulationDelta to show some animation or transition states to provide some Visual Feedback.

在所有偶数处理程序中,我使用了 e.Handled = true 阻止它冒泡。

In all even handlers I have used e.Handled = true to stop it from bubbling up.

在你的场景中,变形不会帮助!

In your scenario Transforms will not  help!


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

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