This documentation is archived and is not being maintained.

PropertyMap Class

Provides a way to translate property values between Windows Forms controls and Windows Presentation Foundation (WPF) elements. 

Namespace:  System.Windows.Forms.Integration
Assembly:  WindowsFormsIntegration (in WindowsFormsIntegration.dll)

[PermissionSetAttribute(SecurityAction.LinkDemand, Name = "FullTrust")]
[PermissionSetAttribute(SecurityAction.InheritanceDemand, Name = "FullTrust")]
public class PropertyMap
<PropertyMap .../>

Use the PropertyMap class to define translations between Windows Forms properties and Windows Presentation Foundation (WPF) properties in a hybrid application. The ElementHost.PropertyMap and WindowsFormsHost.PropertyMap properties on the ElementHost and WindowsFormsHost classes define mappings from one technology to the other.

For more information, see Walkthrough: Mapping Properties Using the ElementHost Control and Walkthrough: Mapping Properties Using the WindowsFormsHost Element.

The following code example shows how to add a mapping for the Margin property to an ElementHost control.

// The AddMarginMapping method adds a new property mapping 
// for the Margin property. 
private void AddMarginMapping()
        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;

The following code example shows how to replace the default mapping for the FlowDirection property on a WindowsFormsHost control.

// The ReplaceFlowDirectionMapping method replaces the   
// default mapping for the FlowDirection property. 
private void ReplaceFlowDirectionMapping()

        new PropertyTranslator(OnFlowDirectionChange));

// The OnFlowDirectionChange method translates a  
// Windows Presentation Foundation FlowDirection value  
// to a Windows Forms RightToLeft value and assigns 
// the result to the hosted control's RightToLeft property. 
private void OnFlowDirectionChange(object h, String propertyName, object value)
    WindowsFormsHost host = h as WindowsFormsHost;
    System.Windows.FlowDirection fd = (System.Windows.FlowDirection)value;
    System.Windows.Forms.CheckBox cb = host.Child as System.Windows.Forms.CheckBox;

    cb.RightToLeft = (fd == System.Windows.FlowDirection.RightToLeft ) ? 
        RightToLeft.Yes : RightToLeft.No;

// The cb_CheckedChanged method handles the hosted control's 
// CheckedChanged event. If the Checked property is true, 
// the flow direction is set to RightToLeft, otherwise it is 
// set to LeftToRight. 
private void cb_CheckedChanged(object sender, EventArgs e)
    System.Windows.Forms.CheckBox cb = sender as System.Windows.Forms.CheckBox;

    wfHost.FlowDirection = ( cb.CheckState == CheckState.Checked ) ? 
            System.Windows.FlowDirection.RightToLeft : 


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0