Classic forms control cannot resize in WPF environment
I've added a regular forms control but I cannot resize it. Instead I have to resize host.
MSDN sample: Hosting a Windows Forms Control in WPF
System.Win开发者_C百科dows.Forms.Integration.WindowsFormsHost host =
new System.Windows.Forms.Integration.WindowsFormsHost();
MaskedTextBox mtbDate = new MaskedTextBox("00/00/0000");
host.Child = mtbDate;
this.grid1.Children.Add(host);
mtbDate.Width = 200; //Not work!
host.Width = 200; //Workaraound...
How can I resize the control, not the host?
This page gives a lot of information about hosting WinForms controls in WPF: http://msdn.microsoft.com/en-us/library/ms744952.aspx
The short story is that you are not supposed to resize the textbox- that will be ignored/overridden. Instead, resize the WindowsFormsHost (either in WPF or via WPF dynamic layout)
精彩评论