开发者

Classic forms control cannot resize in WPF environment

开发者 https://www.devze.com 2023-04-08 16:07 出处:网络
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

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)

0

精彩评论

暂无评论...
验证码 换一张
取 消