InkCanvas.Strokes 属性

定义

获取或设置 Stroke 收集的墨迹 InkCanvas 对象集合。

public:
 property System::Windows::Ink::StrokeCollection ^ Strokes { System::Windows::Ink::StrokeCollection ^ get(); void set(System::Windows::Ink::StrokeCollection ^ value); };
public System.Windows.Ink.StrokeCollection Strokes { get; set; }
member this.Strokes : System.Windows.Ink.StrokeCollection with get, set
Public Property Strokes As StrokeCollection

属性值

StrokeCollection

包含在 Stroke 中的 InkCanvas 对象集合。

示例

以下示例演示如何对同一对象InkCanvas使用两个StrokeCollection对象。 在此示例中,玩家一个和两个玩家分别使用单个“墨迹书写图面”,即使它们共享相同 InkCanvas。 本示例假定 click 事件已连接到事件处理程序。 switchPlayersButton_Click

StrokeCollection player1;
StrokeCollection player2;

void InitializePlayersCanvases()
{
    player1 = inkCanvas1.Strokes;
    player2 = new StrokeCollection();
}

// Use a different "inking surface" for each player.
void switchPlayersButton_Click(object sender, RoutedEventArgs e)
{
    if (StrokeCollection.ReferenceEquals(inkCanvas1.Strokes, player1))
    {
        inkCanvas1.Strokes = player2;
    }
    else
    {
        inkCanvas1.Strokes = player1;
    }
}

void inkCanvas1_StrokesReplaced(object sender, InkCanvasStrokesReplacedEventArgs e)
{
    if (StrokeCollection.ReferenceEquals(e.NewStrokes, player1))
    {
        Title = "Player one's turn";
    }
    else
    {
        Title = "Player two's turn";
    }
}
Private player1 As StrokeCollection
Private player2 As StrokeCollection


Sub InitializePlayersCanvases()

    player1 = inkCanvas1.Strokes
    player2 = New StrokeCollection()

End Sub


' Use a different "inking surface" for each player.
Private Sub switchPlayersButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)

    If StrokeCollection.ReferenceEquals(inkCanvas1.Strokes, player1) Then
        inkCanvas1.Strokes = player2
    Else
        inkCanvas1.Strokes = player1
    End If

End Sub


Private Sub inkCanvas1_StrokesReplaced(ByVal sender As Object, _
                               ByVal e As InkCanvasStrokesReplacedEventArgs)

    If StrokeCollection.ReferenceEquals(e.NewStrokes, player1) Then
        Title = "Player one's turn"
    Else
        Title = "Player two's turn"
    End If

End Sub

以下示例演示如何将 Strokes 某个 InkCanvas 属性绑定到另一个 InkCanvas属性。

<InkCanvas Background="LightGray" 
           Canvas.Top="0" Canvas.Left="0" 
           Height="400" Width="200" Name="ic"/>

<!-- Bind the Strokes of the second InkCavas to the first InkCanvas
     and mirror the strokes along the Y axis.-->
<InkCanvas Background="LightBlue"  
           Canvas.Top="0" Canvas.Left="200" 
           Height="400" Width="200" 
           Strokes="{Binding ElementName=ic, Path=Strokes}">
  <InkCanvas.LayoutTransform>
    <ScaleTransform ScaleX="-1" ScaleY="1" />
  </InkCanvas.LayoutTransform>
</InkCanvas>

注解

依赖项属性信息

标识符字段 StrokesProperty
元数据属性设置为 true

适用于

另请参阅