共用方式為


PointerPointProperties.IsPrimary 屬性

定義

取得值,這個值表示當註冊多個指標時,輸入是否來自主要指標。

public:
 property bool IsPrimary { bool get(); };
bool IsPrimary();
public bool IsPrimary { get; }
var boolean = pointerPointProperties.isPrimary;
Public ReadOnly Property IsPrimary As Boolean

屬性值

Boolean

bool

如果輸入來自指定為主要指標的輸入,則為 True;否則為 false。

範例

此範例會使用不同的彩色橢圓形來顯示與 PointerRoutedEventArgs 相關聯的指標是否為主要指標。

private void MainPage_PointerPressed(object sender, PointerRoutedEventArgs e)
{
    PointerPoint pt = e.GetCurrentPoint(pointerCanvas);
    contacts[pt.PointerId] = pt;
    PointerCounter.Text = contacts.Count.ToString();

    Ellipse ellipse = new Ellipse();
    ellipse.StrokeThickness = 2;
    ellipse.Width = ellipseDiameter;
    ellipse.Height = ellipseDiameter;
    ellipse.Tag = pt.PointerId;
    TranslateTransform translate = new TranslateTransform();
    translate.X = pt.Position.X - ellipseDiameter / 2;
    translate.Y = pt.Position.Y - ellipseDiameter / 2;
    ellipse.RenderTransform = translate;
    pointerCanvas.Children.Add(ellipse);

    if (pt.Properties.IsPrimary == true)
    {
        primaryPointer = pt;
        primaryEllipse = ellipse;
        primaryEllipse.Scale(scaleX: 2, scaleY: 2, centerX: 0, centerY: 0).Start();
        ellipse.Stroke = new SolidColorBrush(Windows.UI.ColorHelper.FromArgb(255, 255, 0, 0));

        // Create the transform
        ScaleTransform scaleTransform = new ScaleTransform();
        scaleTransform.ScaleX = primaryEllipse.Width * 1.25;
        scaleTransform.ScaleY = primaryEllipse.Height * 1.25;
        primaryEllipse.RenderTransform = scaleTransform;

        PointerPrimary.Text = pt.PointerId.ToString();
    }
    else
        ellipse.Stroke = new SolidColorBrush(Windows.UI.ColorHelper.FromArgb(255, 0, 0, 255));

    e.Handled = true;
}

備註

主要指標是目前互動中 (觸控、滑鼠和手寫筆/手寫筆) 的單一指標。

對於滑鼠,主要指標是唯一可以產生滑鼠事件的指標。

對於可有多個並行指標的觸控 () ,主要指標是互動中的第一個接觸點。 對於第一個 PointerPressed 事件之後的任何互動,IsPrimary 會傳回 false。

只有在移除該互動中的所有連絡人,且後續偵測到新的連絡人時,才會註冊新的主指標。

主指標可以執行其他指標無法使用的動作。 例如,當主指標在非作用中視窗上產生 WM_POINTERDOWN 訊息時, 也會將WM_POINTERACTI加值稅E] 訊息傳送至該視窗。

適用於