InkCanvas.CanPaste 方法

定义

指示剪贴板的内容是否可以粘贴到 InkCanvas

public:
 bool CanPaste();
public bool CanPaste ();
member this.CanPaste : unit -> bool
Public Function CanPaste () As Boolean

返回

如果可以粘贴剪贴板的内容,则为 true;否则为 false

示例

以下示例将 元素复制到剪贴板,并将其粘贴到 InkCanvas。 此示例假定有一个名为 的 rect1元素,并且事件 Click 已连接到示例中的事件处理程序。

void copyXamlButton_Click(object sender, RoutedEventArgs e)
{
    string rectString = XamlWriter.Save(rect1);

    DataObject rectangleData = new DataObject(DataFormats.Xaml, rectString);
    Clipboard.SetDataObject(rectangleData);
}

void pasteButton_Click(object sender, RoutedEventArgs e)
{
    if (inkCanvas1.CanPaste())
    {
        inkCanvas1.Paste(new Point(100, 100));
    }
}
Private Sub copyXamlButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)

    'string rectString = Parser.SaveAsXml(rect1);
    Dim rectString As String = XamlWriter.Save(rect1)

    Dim rectangleData As New DataObject(DataFormats.Xaml, rectString)
    Clipboard.SetDataObject(rectangleData)

End Sub


Private Sub pasteButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)

    If inkCanvas1.CanPaste() Then
        inkCanvas1.Paste(New Point(100, 100))
    End If

End Sub

注解

InkCanvas可以支持可扩展应用程序标记语言 (XAML) 格式、墨迹序列化格式 (ISF) 和文本格式的剪贴板数据。

适用于

另请参阅