Reputation: 10055
I want to use the WinForms DateTimePicker in my WPF project.
This works fine with the below xaml.
<WindowsFormsHost HorizontalAlignment="Left" Height="34" Margin="10,10,0,-44" VerticalAlignment="Top" Width="280">
<wf:DateTimePicker Name="DateTimePickerBox" Dock="Fill" Anchor="Right" />
</WindowsFormsHost>
In a Winforms project if i wanted to Anchor to Left, Right, Top and Bottom i would use the below code.
this.dateTimePicker1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
How do i do this in XAML as the Anchor value will only let me assign one.
Upvotes: 1
Views: 1128
Reputation: 14064
Instead of Anchor="Right"
Just write Anchor="Top, Bottom, Left, Right"
Upvotes: 0
Reputation: 18023
Use comma
<WindowsFormsHost HorizontalAlignment="Left" Height="34" Margin="10,10,0,-44" VerticalAlignment="Top" Width="280">
<wf:DateTimePicker Name="DateTimePickerBox" Dock="Fill" Anchor="Right,Left,Bottom,Top" />
</WindowsFormsHost>
Upvotes: 2