DrawingAttributes.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 は、 DrawingAttributes オブジェクトのカスタム プロパティに関連付けされていません。
例
次の例では、 DrawingAttributes オブジェクトからカスタム プロパティを追加および取得する方法を示します。 この例では、 DrawingAttributes オブジェクトがペンか蛍光ペンかを示すプロパティを追加します。
ChangeColors_Click イベント ハンドラーのコードは、InkCanvas オブジェクト (DrawingAttributes) を使用するinkDAのストロークの新しい色をレンダリングします。 この例では、InkCanvasという名前のinkCanvas1があり、DrawingAttributes という名前の 2 つのinkDA オブジェクトと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
注釈
GetPropertyData オブジェクトに追加したカスタム プロパティにアクセスするには、DrawingAttributes メソッドを使用します。 GetPropertyData は、値が設定されていない場合は、組み込みプロパティの既定値を返します。