StrokeCollection.AddPropertyData(Guid, Object) 메서드

정의

사용자 지정 속성을 StrokeCollection에 추가합니다.

public:
 void AddPropertyData(Guid propertyDataId, System::Object ^ propertyData);
public void AddPropertyData (Guid propertyDataId, object propertyData);
member this.AddPropertyData : Guid * obj -> unit
Public Sub AddPropertyData (propertyDataId As Guid, propertyData As Object)

매개 변수

propertyDataId
Guid

사용자 지정 속성과 연결할 Guid입니다.

propertyData
Object

사용자 지정 속성의 값입니다. propertyData는 허용되지 않는 String을 제외하고, Char, Byte, Int16, UInt16, Int32, UInt32, Int64, UInt64, Single, Double, DateTime, Boolean, String, Decimal 또는 이러한 데이터 형식의 배열이어야 합니다.

예외

propertyDataId가 빈 Guid인 경우

또는 propertyDataParameters 섹션에 나열된 허용되는 데이터 형식 중 하나가 아닌 경우

예제

다음 예제에서는 사용자 지정 속성 데이터를 가져와 추가 하는 방법을 보여 줍니다. 합니다 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 메서드를 사용 하면 사용자 지정 속성을 추가할 수는 StrokeCollection합니다. 추가 정보를 포함할 수 있습니다는 StrokeCollection합니다.

적용 대상