简体   繁体   English

Frame.Navigate中的content参数有什么要求?

[英]What are the requirements for the content parameter in Frame.Navigate?

I'm writing a WPF library where I make use of the Frame.Navigate method. 我正在编写一个WPF库,其中使用了Frame.Navigate方法。 I'm curious to know, what are the requirements for the content parameter passed into the method? 我很好奇,传递给方法的content参数有什么要求? Does it require the object to be a subclass of the Page class? 是否要求对象是Page类的子类? If so, then why doesn't it take a Page instead of an object parameter? 如果是这样,那为什么不采用Page而不是object参数呢?

I tried looking into the WPF source code here , but I eventually gave up after 10 methods down. 我尝试在此处查看WPF源代码,但最终在放弃10种方法后放弃了。 MSDN is also pretty vague; MSDN也很模糊。 it just says "the object that contains the content to navigate to." 它只是说“包含要导航到的内容的对象”。

Can someone tell me the requirements for this method? 有人可以告诉我这种方法的要求吗? Obviously something like Frame.Navigate("Hello world") wouldn't work, so what criteria does the parameter need to meet? 显然,诸如Frame.Navigate("Hello world")类的东西不起作用,那么该参数需要满足什么条件?

Thanks for helping. 感谢您的帮助。

Actually Frame.Navigate("Hello world") works without problems. 实际上Frame.Navigate("Hello world")可以正常工作。

There is no limitation on what you can set as the content parameter. 可以设置为content参数的content没有限制。

Quote from WPF Unleashed about Frame : WPF引用关于Frame

The Frame control holds arbitrary content, just like all other content controls, but it isolates the content from the rest of the user interface. 与所有其他内容控件一样, Frame控件可保存任意内容,但是它将内容与用户界面的其余部分隔离开来。 For example, properties that would normally be inherited down the element tree stop when they reach the Frame . 例如,通常会在元素树下继承的属性在到达Frame时停止。 In many respects, WPF Frame s act like frames in HTML. 在许多方面,WPF Frame的行为类似于HTML中的框架。

So it's just another content control, which separates its content from the rest of the application (by not inheriting properties) and offering built-in navigation. 因此,它只是另一个内容控件,它将内容与应用程序的其余部分分离(通过不继承属性)并提供内置导航。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM