StrokeCollection.ContainsPropertyData(Guid) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
返回一个值,指出指定的自定义属性标识符是否在 StrokeCollection 中。
public:
bool ContainsPropertyData(Guid propertyDataId);
public bool ContainsPropertyData (Guid propertyDataId);
member this.ContainsPropertyData : Guid -> bool
Public Function ContainsPropertyData (propertyDataId As Guid) As Boolean
参数
- propertyDataId
- Guid
要在 Guid 中定位的 StrokeCollection。
返回
如果指定的自定义属性标识符在 StrokeCollection 中,则返回 true
;否则返回 false
。
示例
以下示例演示如何检查 中的 StrokeCollection自定义属性。 如果自定义属性已与 timestamp
相关联,则示例获取该自定义属性并显示保存 时间 StrokeCollection 。 此示例假定有一个名为 InkCanvas 的 inkCanvas1
。
Guid timestamp = new Guid("12345678-9012-3456-7890-123456789012");
// Add a timestamp to the StrokeCollection.
private void AddTimestamp_Click(object sender, RoutedEventArgs e)
{
inkCanvas1.Strokes.AddPropertyData(timestamp, DateTime.Now);
}
// Get the timestamp of the StrokeCollection.
private void GetTimestamp_Click(object sender, RoutedEventArgs e)
{
if (inkCanvas1.Strokes.ContainsPropertyData(timestamp))
{
object date = inkCanvas1.Strokes.GetPropertyData(timestamp);
if (date is DateTime)
{
MessageBox.Show("This StrokeCollection's timestamp is " +
((DateTime)date).ToString());
}
}
else
{
MessageBox.Show(
"The StrokeCollection does not have a timestamp.");
}
}
Private timestamp As New Guid("12345678-9012-3456-7890-123456789012")
' Add a timestamp to the StrokeCollection.
Private Sub AddTimestamp_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
inkCanvas1.Strokes.AddPropertyData(timestamp, DateTime.Now)
End Sub
' Get the timestamp of the StrokeCollection.
Private Sub GetTimestamp_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
If inkCanvas1.Strokes.ContainsPropertyData(timestamp) Then
Dim savedDate As Object = inkCanvas1.Strokes.GetPropertyData(timestamp)
If TypeOf savedDate Is DateTime Then
MessageBox.Show("This StrokeCollection's timestamp is " & _
CType(savedDate, DateTime).ToString())
End If
Else
MessageBox.Show("The StrokeCollection does not have a timestamp.")
End If
End Sub