Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ElementHost.PropertyMap Property

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

Namespace: System.Windows.Forms.Integration
Assembly: WindowsFormsIntegration (in windowsformsintegration.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public PropertyMap PropertyMap { get; }
/** @property */
public PropertyMap get_PropertyMap ()

public function get PropertyMap () : PropertyMap

Not applicable.

Property Value

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

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 Property Mapping.

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.

// 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;
}

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2015 Microsoft