我想做这样的事情:
var iFrame = new Frame();
var iPage = new Page(new Uri("/Views/MyPage.xaml", UriKind.Relative));
// ^ this must be the parameter on creating the page
iFrame.Content = iView;
tabCtrl.Content = iFrame;
其中,我想使用路径打开页面,而不是像这样实例化功能正确的页面本身:
var iFrame = new Frame();
var iPage = new MyPage();
iFrame.Content = iView;
tabCtrl.Content = iFrame;
我的想法是为存储在数据库中的页面使用维护路径。 有什么想法吗?
最佳答案
是这样的吗?
System.Uri resource = new System.Uri(@"Views\MyPage.xaml", System.UriKind.RelativeOrAbsolute);
Something.Content = System.Windows.Application.LoadComponent(resource);
关于c# - 使用路径/URI 打开一个 wpf 页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34171470/