我正在尝试使用用户创建的UserControl实现布局之类的导航 .
我有一个Silverlight页面,通过将内容设置为框架元素来加载Usercontrol .
UserControl1 uc1 = new UserControl1();
this.Frame.Content = uc1;
类似地,我在每个UserControl中都有一个Frame,其中内容设置为Frame .
这很好用 .
Problem: 我有目前的情况
| UserControl1 | UserControl2 | UserControl3
UserControl1 | |儿童|
UserControl2 |父母| |儿童
UserControl3 | |父母|
所以现在我想要实现的是当用户从UserControl1打开UserControl2时,我需要能够从UserControl2向后移动到父(UserControl1) in the same state it was before .
这有可能吗?如果是,那应该怎么做?任何提示,代码,文章参考赞赏...
Reason:
我试图避免在页面查询中传递变量并使用usercontrols .
Scenario:
例如,如果用户在UserControl1内的文本框中编写“Hello World”并按下按钮,则加载UserControl2 . 在UserControl2中按OK后返回UserControl1,文本框仍然显示“Hello World”
希望我很清楚 . 如果需要澄清,请与我们联系 .
干杯
2 回答
是的,这是可能的,但你的控件不应该是UserControls,而是从Page继承,你应该使用Frame的Navigate方法来设置第一页
然后,要从第1页导航到第2页,请使用Page的NavigationService
以下是您可能会这样做的示例: