WindowsFormsHost.PropertyMap Proprietà
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Ottiene la mappa delle proprietà che determina come l'impostazione delle proprietà sull'elemento WindowsFormsHost influisce sul controllo Windows Forms ospitato.
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
Valore della proprietà
Oggetto PropertyMap che esegue il mapping WindowsFormsHost delle proprietà alle proprietà nel controllo Windows Forms ospitato.
Esempio
Nell'esempio di codice seguente viene illustrato come aggiungere un mapping per la FlowDirection proprietà a un WindowsFormsHost controllo.
// 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
Commenti
Le tecnologie Windows Forms e WPF hanno due modelli di proprietà simili ma diversi. Il mapping delle proprietà supporta l'interoperabilità tra le due architetture. Per altre informazioni, vedere Mapping di proprietà di Windows Form e WPF.