WindowsFormsHost.PropertyMap Propriété
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Obtient le mappage des propriétés qui détermine la manière dont la définition de propriétés sur l’élément WindowsFormsHost affecte le contrôle Windows Forms hébergé.
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
Valeur de propriété
Qui PropertyMap mappe WindowsFormsHost les propriétés aux propriétés sur le contrôle de Windows Forms hébergé.
Exemples
L’exemple de code suivant montre comment ajouter un mappage pour la FlowDirection propriété à un WindowsFormsHost contrôle.
// 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
Remarques
Les technologies Windows Forms et WPF ont deux modèles de propriétés similaires mais différents. Le mappage de propriétés prend en charge l’interopérabilité entre les deux architectures. Pour plus d’informations, consultez Mappage de propriétés Windows Forms et WPF.