StrokeCollection.GetPropertyData(Guid) メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
指定した Guidに関連付けられているカスタム プロパティの値を返します。
public:
System::Object ^ GetPropertyData(Guid propertyDataId);
public object GetPropertyData(Guid propertyDataId);
member this.GetPropertyData : Guid -> obj
Public Function GetPropertyData (propertyDataId As Guid) As Object
パラメーター
返品
指定した Guidに関連付けられているカスタム プロパティの値。
例外
propertyDataId は、 StrokeCollectionのカスタム プロパティに関連付けされていません。
例
次の例では、カスタム プロパティ データを追加して取得する方法を示します。
AddTimeStamp_Click メソッドは、AddPropertyData メソッドを使用して、現在の時刻をStrokeCollectionに追加します。
GetTimeStap_Click メソッドは、GetPropertyData メソッドを使用して、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
注釈
AddPropertyDataメソッドとGetPropertyDataメソッドを使用すると、カスタム プロパティをStrokeCollectionに追加できます。 その後、 StrokeCollectionで追加情報を含めることができます。