UIElement.IsManipulationEnabled 屬性

定義

取得或設定值,這個值表示是否在此 UIElement 上啟用操作事件。

C#
public bool IsManipulationEnabled { get; set; }

屬性值

如果在這個 UIElement 上啟用操作事件則為 true,否則為 false。 預設為 false

範例

下列範例會建立具有紅色 Rectangle 的應用程式。 IsManipulationEnabledRectangle 的 屬性設定為 true,而應用程式的視窗會 ManipulationStarting 訂閱 、 ManipulationDeltaManipulationInertiaStarting 事件。 本範例是逐步解說 :建立您的第一個觸控應用程式中較大範例的一部分。

XAML
<Window x:Class="BasicManipulation.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Move, Size, and Rotate the Square"
        WindowState="Maximized"
        ManipulationStarting="Window_ManipulationStarting"
        ManipulationDelta="Window_ManipulationDelta"
        ManipulationInertiaStarting="Window_InertiaStarting">
  <Window.Resources>

    <!--The movement, rotation, and size of the Rectangle is 
        specified by its RenderTransform.-->
    <MatrixTransform x:Key="InitialMatrixTransform">
      <MatrixTransform.Matrix>
        <Matrix OffsetX="200" OffsetY="200"/>
      </MatrixTransform.Matrix>
    </MatrixTransform>

  </Window.Resources>

  <Canvas>
    <Rectangle Fill="Red" Name="manRect"
                 Width="200" Height="200" 
                 RenderTransform="{StaticResource InitialMatrixTransform}"
                 IsManipulationEnabled="true" />
  </Canvas>
</Window>

備註

如果您想要 UIElement 接收 、 ManipulationStartedManipulationDeltaManipulationInertiaStartingManipulationBoundaryFeedbackManipulationCompleted 事件, ManipulationStarting 請將此屬性設定為 true。 如需操作的詳細資訊,請參閱 輸入概觀。 如需回應操作的應用程式範例,請參閱 逐步解說:建立您的第一個觸控應用程式

適用於

產品 版本
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10