StrokeCollection.AddPropertyData(Guid, Object) Methode
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Voegt een aangepaste eigenschap toe aan de 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)
Parameters
- propertyData
- Object
De waarde van de aangepaste eigenschap.
propertyDatamoet van het type Char, Byte, Int16, UInt16, Int32UInt32Int64, UInt64, Single, , DoubleDateTime, Boolean, StringDecimal of een matrix van deze gegevenstypen zijn, behalve String, die niet is toegestaan.
Uitzonderingen
propertyDataId is leeg Guid.
– of –
propertyData is geen van de toegestane gegevenstypen die worden vermeld in de Parameters sectie.
Voorbeelden
In het volgende voorbeeld ziet u hoe u aangepaste eigenschapsgegevens toevoegt en opvragen. De AddTimeStamp_Click methode gebruikt de AddPropertyData methode om de huidige tijd toe te voegen aan de StrokeCollection. De GetTimeStap_Click methode gebruikt de GetPropertyData methode om de tijdstempel op te halen uit de StrokeCollection. In dit voorbeeld wordt ervan uitgegaan dat er een InkCanvas aangeroepen inkCanvas1naam is.
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
Opmerkingen
Met de AddPropertyData methode kunt u aangepaste eigenschappen toevoegen aan een StrokeCollection. U kunt dan extra informatie met een StrokeCollection.