DrawingAttributes.ContainsPropertyData(Guid) 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.
Retourneert een waarde die aangeeft of de opgegeven eigenschapsgegevens-id zich in het DrawingAttributes object bevindt.
public:
bool ContainsPropertyData(Guid propertyDataId);
public bool ContainsPropertyData(Guid propertyDataId);
member this.ContainsPropertyData : Guid -> bool
Public Function ContainsPropertyData (propertyDataId As Guid) As Boolean
Parameters
- propertyDataId
- Guid
De Guid te zoeken in het DrawingAttributes object.
Retouren
true als de opgegeven eigenschapsgegevens-id zich in het DrawingAttributes object bevindt; falseanders.
Voorbeelden
In het volgende voorbeeld ziet u hoe u een aangepaste eigenschap toevoegt en ophaalt uit het DrawingAttributes object. In het voorbeeld wordt een eigenschap toegevoegd die aangeeft of het DrawingAttributes object een pen of markeerstift is. De ChangeColors_Click gebeurtenis-handler wijzigt alle pennenstreken die zijn geplaatst InkCanvas met een DrawingAttributes aangeroepen inkDA kleur. In dit voorbeeld wordt ervan uitgegaan dat er een InkCanvas naam inkCanvas1is en dat er twee DrawingAttributes objecten zijn met de naam inkDA, en highlighterDA.
Guid purposeGuid = new Guid("12345678-9012-3456-7890-123456789012");
string penValue = "pen";
string highlighterValue = "highlighter";
// Add a property to each DrawingAttributes object to
// specify its use.
private void AssignDrawingAttributesInstrument()
{
inkDA.AddPropertyData(purposeGuid, penValue);
highlighterDA.AddPropertyData(purposeGuid, highlighterValue);
}
// Change the color of the ink that on the InkCanvas that used the pen.
void ChangeColors_Click(Object sender, RoutedEventArgs e)
{
foreach (Stroke s in inkCanvas1.Strokes)
{
if (s.DrawingAttributes.ContainsPropertyData(purposeGuid))
{
object data = s.DrawingAttributes.GetPropertyData(purposeGuid);
if ((data is string) && ((string)data == penValue))
{
s.DrawingAttributes.Color = Colors.Black;
}
}
}
}
Private purposeGuid As New Guid("12345678-9012-3456-7890-123456789012")
Private penValue As String = "pen"
Private highlighterValue As String = "highlighter"
' Add a property to each DrawingAttributes object to
' specify its use.
Private Sub AssignDrawingAttributesInstrument()
inkDA.AddPropertyData(purposeGuid, penValue)
highlighterDA.AddPropertyData(purposeGuid, highlighterValue)
End Sub
' Change the color of the ink that on the InkCanvas that used the pen.
Private Sub ChangeColors_Click(ByVal sender As [Object], _
ByVal e As RoutedEventArgs)
Dim s As Stroke
For Each s In inkCanvas1.Strokes
If s.DrawingAttributes.ContainsPropertyData(purposeGuid) Then
Dim data As Object = s.DrawingAttributes.GetPropertyData(purposeGuid)
If TypeOf data Is String AndAlso CStr(data) = penValue Then
s.DrawingAttributes.Color = Colors.Black
End If
End If
Next s
End Sub