次の方法で共有


StylusPoint.PressureFactor Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets the pressure factor of the stylus on the screen.

Namespace:  System.Windows.Input
Assembly:  System.Windows (in System.Windows.dll)

Syntax

'Declaration
Public Property PressureFactor As Single
public float PressureFactor { get; set; }

Property Value

Type: System.Single
The pressure factor of the stylus on the screen. The default is 0.5.

Exceptions

Exception Condition
ArgumentOutOfRangeException

PressureFactoris set to a value that is less than 0 or greater than 1.0.

Remarks

The permitted range is 0 to 1.0. Values obtained from input will always be within this range. Setting the value to outside this range causes an exception to be thrown.

The value is a factor of the total possible pressure.

The typical scenario for this property is to modify the DrawingAttributes based on the PressureFactor captured in a StylusPoint obtained from user input. Notice that while PressureFactor comes from individual points, DrawingAttributes must apply to an entire Stroke.

XAML Attribute Usage

<StylusPoint PressureFactor="double"/>

Examples

The following code example demonstrates how to get the member Y property. This is part of a larger example available in StylusPoint class overview.

    'StylusPoint objects are collected from the MouseEventArgs and added to MyStroke
    Private Sub MyIP_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs)
        If (Not (MyStroke) Is Nothing) Then
            MyStroke.StylusPoints.Add(e.StylusDevice.GetStylusPoints(MyIP))
            XTB.Text = ("" + e.StylusDevice.GetStylusPoints(MyIP)(0).X)
            YTB.Text = ("" + e.StylusDevice.GetStylusPoints(MyIP)(0).Y)
            PressureTB.Text = ("" + e.StylusDevice.GetStylusPoints(MyIP)(0).PressureFactor)
        End If
    End Sub

//StylusPoint objects are collected from the MouseEventArgs and added to MyStroke
private void MyIP_MouseMove(object sender, MouseEventArgs e)
{
    if (MyStroke != null)
    {
        MyStroke.StylusPoints.Add(e.StylusDevice.GetStylusPoints(MyIP));
        XTB.Text = "" + e.StylusDevice.GetStylusPoints(MyIP)[0].X;
        YTB.Text = "" + e.StylusDevice.GetStylusPoints(MyIP)[0].Y;
        PressureTB.Text = "" + e.StylusDevice.GetStylusPoints(MyIP)[0].PressureFactor;
    }
}

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.