开发者

WPF load new usercontrol within same window

开发者 https://www.devze.com 2023-02-09 08:19 出处:网络
I have a WPF window that I want replaced with another user control on a开发者_如何学运维 button click instead of a new window with .Show(). How can I do this? If your Window has a Grid \'LayoutRoot\'

I have a WPF window that I want replaced with another user control on a开发者_如何学运维 button click instead of a new window with .Show(). How can I do this?


If your Window has a Grid 'LayoutRoot' with the currrent Window contents within it, you can change the contents in code-behind as follows:

LayoutRoot.Children.Clear()
LayoutRoot.Children.Add(new MyUserControl());

Where MyUserControl is your new UserControl.

0

精彩评论

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