This documentation is archived and is not being maintained.

WindowsFormsHost.PropertyMap Property

Gets the property map that determines how setting properties on the WindowsFormsHost element affects the hosted Windows Forms control.

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

'Declaration
Public ReadOnly Property PropertyMap As PropertyMap
'Usage
Dim instance As WindowsFormsHost 
Dim value As PropertyMap 

value = instance.PropertyMap
You cannot set this property in XAML.

Property Value

Type: System.Windows.Forms.Integration.PropertyMap
A PropertyMap that maps WindowsFormsHost properties to properties on the hosted Windows Forms control.

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.

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

' The ReplaceFlowDirectionMapping method replaces the 
' default mapping for the FlowDirection property. 
Private Sub ReplaceFlowDirectionMapping()

    wfHost.PropertyMap.Remove("FlowDirection")

    wfHost.PropertyMap.Add( _
        "FlowDirection", _
        New PropertyTranslator(AddressOf OnFlowDirectionChange))
End Sub 


' 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 Sub OnFlowDirectionChange( _
ByVal h As Object, _
ByVal propertyName As String, _
ByVal value As Object)

    Dim host As WindowsFormsHost = h

    Dim fd As System.Windows.FlowDirection = _
        CType(value, System.Windows.FlowDirection)

    Dim cb As System.Windows.Forms.CheckBox = host.Child

    cb.RightToLeft = IIf(fd = System.Windows.FlowDirection.RightToLeft, _
        RightToLeft.Yes, _
        RightToLeft.No)

End Sub 


' 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 Sub cb_CheckedChanged( _
ByVal sender As Object, _
ByVal e As EventArgs)

    Dim cb As System.Windows.Forms.CheckBox = sender

    wfHost.FlowDirection = IIf(cb.CheckState = CheckState.Checked, _
    System.Windows.FlowDirection.RightToLeft, _
    System.Windows.FlowDirection.LeftToRight)

End Sub

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
Show: