zoukankan      html  css  js  c++  java
  • Windows Phone 7 ManipulationStarted 事件

    System.WindowsUIElement.ManipulationStarted 事件

    当输入设备对 UIElement 对象开始操作时发生。

    ManipulationStarted 事件在 ManipulationStarting 事件之后发生。 使用 ManipulationStartedEventArgs,您可以执行以下操作。

    使用 ManipulationContainer 属性获取操作位置所相对的元素。

    使用 ManipulationOrigin 属性获取操作的原点。

    通过调用 Complete 方法来取消该操作。

    小例子:点击界面,触发事件  随机生成hello world

    <!--LayoutRoot contains the root grid where all other page content is placed-->
        <Grid x:Name="LayoutRoot" Background="Transparent">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>

            <!--TitlePanel contains the name of the application and page title-->
            <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
                <TextBlock x:Name="ApplicationTitle" Text="UIElement对象操作开始触发事件" Style="{StaticResource PhoneTextNormalStyle}"/>
                <TextBlock x:Name="PageTitle" Text="main page" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
            </StackPanel>

            <!--ContentPanel - place additional content here-->
            <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
                <TextBlock Name="txtblk"
                           Text=""
                           HorizontalAlignment="Center"
                           VerticalAlignment="Center" />
            </Grid>
        </Grid>

    事件处理

    //在 ManipulationStarted 事件发生时调用,当输入设备对 UIElement 对象开始操作时发生。
            protected override void OnManipulationStarted(ManipulationStartedEventArgs args)
            {
                TextBlock newTextBlock = new TextBlock();
                newTextBlock.Text = "Hello, world!";
                newTextBlock.HorizontalAlignment = HorizontalAlignment.Left;//父元素水平最左边
                newTextBlock.VerticalAlignment = VerticalAlignment.Top;//父元素垂直最左边
                newTextBlock.Margin = new Thickness(
                    (ContentPanel.ActualWidth - txtblk.ActualWidth) * rand.NextDouble(),
                    (ContentPanel.ActualHeight - txtblk.ActualHeight) * rand.NextDouble(),
                    0, 0);
                //Thickness 结构四个 Double 值分别描述矩形的四个边(Left、Top、Right 和 Bottom)。
                ContentPanel.Children.Add(newTextBlock);

                args.Complete();//完成操作
                args.Handled = true;//获取或设置将路由事件标记为已处理的值。设置为 true,则可以防止事件路由路径上的大多数处理程序再次处理同一事件。
                base.OnManipulationStarted(args);//务必调用基本类的 OnManipulationStarted 方法,从而基本类接收该事件
            }

  • 相关阅读:
    springCloud你要了解的都在这(方向性)
    十分钟了解 spring cloud
    JDK 自带压缩解压流
    JAVA自带API的压缩与解压
    Java实现多文件压缩打包的方法
    芯片超Intel,盈利比肩Apple,三星成科技界"全民公敌"
    一个不知道体谅难处,一个说话伤人自尊,矛盾的种子已悄悄埋下
    一天杀了两千宦官(袁绍也曾仗义过,为东汉彻底除去了宦官祸害。何进却心软了,任凭袁绍怎么劝说,何进就是不下手)
    WMWaire使用FreeNAS硬盘挂载、Raid0
    net share列出了Windows的默认共享(包括C盘)
  • 原文地址:https://www.cnblogs.com/linzheng/p/1955593.html
Copyright © 2011-2022 走看看