Export (0) Print
Expand All

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

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

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Show:
© 2014 Microsoft