从用户控件页面访问MainWindow的控件。 WPF C# [英] Accessing MainWindow's controls from a user control page. WPF C#
本文介绍了从用户控件页面访问MainWindow的控件。 WPF C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在MainWindow中有一个页面转换(一个控件),我有很多用户控件页面,我想从我的用户控制页面访问MainWindow中的页面转换吗?我怎么做?我尝试过的
:
I have a page transition ( a control ) in the MainWindow , I have many user control pages , I want to access the page transition in the MainWindow from my user control page ? How do I do that? I tried :
Story page = new Story();
NavigationService nav = NavigationService.GetNavigationService(this);
// Navigate to the page, using the NavigationService
// if (nav != null)
// {
// nav.Navigate(page);
MainWindow test = new MainWindow();
test.pageTransition1.ShowPage(page);
// }
推荐答案
Application.Current.MainWindow
使用此功能,您可以访问MainWindow在任何地方。
Using this you can access the MainWindow from any place.
这篇关于从用户控件页面访问MainWindow的控件。 WPF C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文