WPF load new usercontrol within same window
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.
精彩评论