我可以在contentcontrol / frame中打开一个窗口 [英] Can i open a window inside the contentcontrol/frame
问题描述
我是WPF的新手。我在这里知道,我们可以在一个wrappanel / frame / contentcontrol或任何其他面板中加载WPF窗口。
我有一个带有框架的MainPage。在菜单上选择我需要在该框架内打开一个新的wpf窗口。我尝试使用page和usercontrol。问题是,当功能完成时,页面和用户控件无法关闭(例如: - 学生注册)。或者是否有任何其他方法可以打开注册窗口并在完成注册后关闭它。
提前感谢...
Hi, I'm new in WPF. I'm here to know, can we load a WPF windows inside a wrappanel/ frame/ contentcontrol or any other panel.
I'm having a MainPage with a frame. On menu select i need to open a new wpf window inside that frame. I tried it on using page and usercontrol. What the problem is, the page and usercontrol can't close when the function is completed (eg:- student registration). Or is there is any other methods to open Registration window and close it after finishing the registration.
Thanks in advance...
推荐答案
您可以在主页面中使用Tab控件,然后为您的学生注册表单创建用户控件。在选择学生注册菜单项时,添加一个TabItem并将学生注册用户控件添加到TabItem。注册完成后,您可以关闭TabItem。
You can have a Tab control in the main page, then create user control for your student registration form. On selection of student registration menu item add one TabItem and add student registration user control to TabItem. Once registration completed you can close the TabItem.
您可以在单个WPF窗口中创建多个用户控件。
Usercontrol xaml :您的设计需要以表格形式显示
Usercontrol xaml.cs:该页面的逻辑,如事件处理等..
Mainwindow Xaml:
grid
内容控制x:name =cntctrlxmlns:x =#unknown/>
/ grid
Mainwindow xaml.cs:
使用//名称空间usercontrol ...
//你需要编写这段代码的构造函数
cntctrl.content = nameofusercontrol ();
认为它可以帮助你...
You can create number of user controls in single WPF window.
Usercontrol xaml: Your design which need to be displayed in Form
Usercontrol xaml.cs: Logic for that page like event handling etc..
Mainwindow Xaml:
grid
content control x:name="cntctrl" xmlns:x="#unknown" />
/grid
Mainwindow xaml.cs:
using //Name space of usercontrol...
//constructor you need to write this code
cntctrl.content=nameofusercontrol();
Think it helps you...
这篇关于我可以在contentcontrol / frame中打开一个窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!