WPF root element is not valid for navigation

后端 未结 3 791
天命终不由人
天命终不由人 2021-01-03 04:50

I am converting a WPF XBAP app to a WPF desktop app. I have it running on the desktop, but am now trying to change the Page references to Window references.



        
3条回答
  •  悲哀的现实
    2021-01-03 05:11

    Its not entirely accurate about it not being possible to host a window in a frame, the following code will do it for you

        public void HostWindowInFrame(Frame fraContainer, Window win) {
            object tmp = win.Content;
            win.Content = null;
            fraContainer.Content = new ContentControl() { Content = tmp };
        }
    

提交回复
热议问题