ElementHost.PropertyMap Property

Definition

Gets the property map, which determines how setting properties on the ElementHost control affects the hosted Windows Presentation Foundation (WPF) element.

C#
[System.ComponentModel.Browsable(false)]
public System.Windows.Forms.Integration.PropertyMap PropertyMap { get; }

Property Value

A PropertyMap that maps ElementHost to properties on the hosted WPF element.

Attributes

Examples

The following code example demonstrates how to use the PropertyMap property to translate the Margin property for a hosted WPF element. For more information, see Walkthrough: Mapping Properties Using the ElementHost Control.

C#
// The AddMarginMapping method adds a new property mapping
// for the Margin property.
private void AddMarginMapping()
{
    elemHost.PropertyMap.Add(
        "Margin",
        new PropertyTranslator(OnMarginChange));
}

// The OnMarginChange method implements the mapping 
// from the Windows Forms Margin property to the
// Windows Presentation Foundation Margin property.
//
// The provided Padding value is used to construct 
// a Thickness value for the hosted element's Margin
// property.
private void OnMarginChange(object h, String propertyName, object value)
{
    ElementHost host = h as ElementHost;
    Padding p = (Padding)value;
    System.Windows.Controls.Button wpfButton = 
        host.Child as System.Windows.Controls.Button;

    Thickness t = new Thickness(p.Left, p.Top, p.Right, p.Bottom );

    wpfButton.Margin = t;
}

Remarks

The Windows Forms and WPF technologies have two similar but different property models. Property mapping supports interoperation between the two architectures. For more information, see Windows Forms and WPF Property Mapping.

Applies to

Produit Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

See also