Aracılığıyla paylaş


PropertyMap.Item[String] Özellik

Tanım

Verilen özellik için temsilciyi PropertyTranslator alır veya ayarlar.

public:
 property System::Windows::Forms::Integration::PropertyTranslator ^ default[System::String ^] { System::Windows::Forms::Integration::PropertyTranslator ^ get(System::String ^ propertyName); void set(System::String ^ propertyName, System::Windows::Forms::Integration::PropertyTranslator ^ value); };
public System.Windows.Forms.Integration.PropertyTranslator this[string propertyName] { get; set; }
member this.Item(string) : System.Windows.Forms.Integration.PropertyTranslator with get, set
Default Public Property Item(propertyName As String) As PropertyTranslator

Parametreler

propertyName
String

Eşlenecek özelliğin adı.

Özellik Değeri

PropertyTranslator tarafından propertyNamebelirtilen özelliğe karşılık gelen temsilci.

Özel durumlar

propertyName veya null boş bir dizedir; belirtilen PropertyTranslator temsilci şeklindedir null.

tarafından propertyName verilen özellik üzerinde SourceObjectyok.

Örnekler

Aşağıdaki kod örneği, bir ElementHost denetimin PropertyTranslator özelliği için temsilcinin BackColor nasıl alınacağı gösterilmektedir.

// The ExtendBackColorMapping method adds a property
// translator if a mapping already exists.
private void ExtendBackColorMapping()
{
    if (elemHost.PropertyMap["BackColor"] != null)
    {
        elemHost.PropertyMap["BackColor"] += 
            new PropertyTranslator(OnBackColorChange);
    }
}

// The OnBackColorChange method assigns a specific image 
// to the hosted element's Background property.
private void OnBackColorChange(object h, String propertyName, object value)
{
    ElementHost host = h as ElementHost;
    System.Windows.Controls.Button wpfButton = 
        host.Child as System.Windows.Controls.Button;

    ImageBrush b = new ImageBrush(new BitmapImage(
        new Uri(@"file:///C:\WINDOWS\Santa Fe Stucco.bmp")));
    wpfButton.Background = b;
}
' The ExtendBackColorMapping method adds a property
' translator if a mapping already exists.
Private Sub ExtendBackColorMapping()

    If elemHost.PropertyMap("BackColor") IsNot Nothing Then

        elemHost.PropertyMap("BackColor") = PropertyTranslator.Combine( _
            elemHost.PropertyMap("BackColor"), _
            PropertyTranslator.CreateDelegate( _
            GetType(PropertyTranslator), _
            Me, _
            "OnBackColorChange"))
    End If

End Sub


' The OnBackColorChange method assigns a specific image 
' to the hosted element's Background property.
Private Sub OnBackColorChange( _
ByVal h As Object, _
ByVal propertyName As String, _
ByVal value As Object)

    Dim host As ElementHost = h
    Dim wpfButton As System.Windows.Controls.Button = host.Child
    Dim b As New ImageBrush(New BitmapImage( _
        New Uri("file:///C:\WINDOWS\Santa Fe Stucco.bmp")))
    wpfButton.Background = b

End Sub

Aşağıdaki kod örneği, bir WindowsFormsHost denetimin PropertyTranslator özelliği için temsilcinin Background nasıl alınacağı gösterilmektedir.

// The ExtendBackgroundMapping method adds a property
// translator if a mapping already exists.
private void ExtendBackgroundMapping()
{
    if (wfHost.PropertyMap["Background"] != null)
    {
        wfHost.PropertyMap["Background"] += new PropertyTranslator(OnBackgroundChange);
    }
}

// The OnBackgroundChange method assigns a specific image 
// to the hosted control's BackgroundImage property.
private void OnBackgroundChange(object h, String propertyName, object value)
{
    WindowsFormsHost host = h as WindowsFormsHost;
    System.Windows.Forms.CheckBox cb = host.Child as System.Windows.Forms.CheckBox;
    ImageBrush b = value as ImageBrush;

    if (b != null)
    {
        cb.BackgroundImage = new System.Drawing.Bitmap(@"C:\WINDOWS\Santa Fe Stucco.bmp");
    }
}
' The ExtendBackgroundMapping method adds a property
' translator if a mapping already exists.
Private Sub ExtendBackgroundMapping() 
    If wfHost.PropertyMap("Background") IsNot Nothing Then

        wfHost.PropertyMap("Background") = PropertyTranslator.Combine( _
        wfHost.PropertyMap("Background"), _
        PropertyTranslator.CreateDelegate( _
            GetType(PropertyTranslator), _
            Me, _
            "OnBackgroundChange"))
    End If

End Sub


' The OnBackgroundChange method assigns a specific image 
' to the hosted control's BackgroundImage property.
Private Sub OnBackgroundChange(ByVal h As Object, ByVal propertyName As String, ByVal value As Object) 
    Dim host As WindowsFormsHost = h 
    Dim cb As System.Windows.Forms.CheckBox = host.Child 
    Dim b As ImageBrush = value 
    
    If Not (b Is Nothing) Then
        cb.BackgroundImage = New System.Drawing.Bitmap("C:\WINDOWS\Santa Fe Stucco.bmp")
    End If

End Sub

Açıklamalar

ayarı yapılırken, için propertyNameyoksaPropertyTranslator, yeni temsilci öğesine PropertyMapeklenir. için propertyNamezaten bir PropertyTranslator varsa, değiştirilir.

Şunlara uygulanır

Ayrıca bkz.