WindowsFormsHost.PropertyMap 속성

정의

호스팅된 Windows Forms 컨트롤에 영향을 주는 WindowsFormsHost 요소의 속성을 설정하는 방법을 결정하는 속성 맵을 가져옵니다.

public:
 property System::Windows::Forms::Integration::PropertyMap ^ PropertyMap { System::Windows::Forms::Integration::PropertyMap ^ get(); };
public System.Windows.Forms.Integration.PropertyMap PropertyMap { get; }
member this.PropertyMap : System.Windows.Forms.Integration.PropertyMap
Public ReadOnly Property PropertyMap As PropertyMap

속성 값

PropertyMap

A PropertyMap 매핑되는 WindowsFormsHost 호스팅된 Windows Forms 컨트롤에서 속성에는 속성입니다.

예제

다음 코드 예제에 대 한 매핑을 추가 하는 방법을 보여 줍니다 합니다 FlowDirection 속성을 WindowsFormsHost 제어 합니다.

// The ReplaceFlowDirectionMapping method replaces the  
// default mapping for the FlowDirection property.
private void ReplaceFlowDirectionMapping()
{
    wfHost.PropertyMap.Remove("FlowDirection");

    wfHost.PropertyMap.Add(
        "FlowDirection",
        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 : 
            System.Windows.FlowDirection.LeftToRight;
}
' 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 Forms 및 WPF 기술에는 두 가지 서로 유사 하지만 다른 속성 모델이 포함 됩니다. 속성 매핑 두 아키텍처 간의 상호 운용을 지원 합니다. 자세한 내용은 Windows Forms 및 WPF 속성 매핑을 참조하세요.

적용 대상

추가 정보