Frame.Navigate中content参数有什么要求?
What are the requirements for the content parameter in Frame.Navigate?
我正在编写一个 WPF 库,我在其中使用 Frame.Navigate
method. I'm curious to know, what are the requirements for the content
parameter passed into the method? Does it require the object to be a subclass of the Page class?如果是这样,那为什么不使用 Page 而不是对象参数?
我试着查看 WPF 源代码 here, but I eventually gave up after 10 methods down. MSDN is also pretty vague; it just says "the object that contains the content to navigate to."
有人能告诉我这个方法的要求吗?显然像Frame.Navigate("Hello world")
这样的东西是行不通的,那么参数需要满足什么条件呢?
感谢您的帮助。
实际上 Frame.Navigate("Hello world")
没有问题。
对于可以设置为 content
参数的内容没有限制。
来自 WPF Unleashed 关于 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. For example, properties that would normally be inherited
down the element tree stop when they reach the Frame
. In many
respects, WPF Frame
s act like frames in HTML.
所以它只是另一个内容控件,它将其内容与应用程序的其余部分分开(通过不继承属性)并提供内置导航。
我正在编写一个 WPF 库,我在其中使用 Frame.Navigate
method. I'm curious to know, what are the requirements for the content
parameter passed into the method? Does it require the object to be a subclass of the Page class?如果是这样,那为什么不使用 Page 而不是对象参数?
我试着查看 WPF 源代码 here, but I eventually gave up after 10 methods down. MSDN is also pretty vague; it just says "the object that contains the content to navigate to."
有人能告诉我这个方法的要求吗?显然像Frame.Navigate("Hello world")
这样的东西是行不通的,那么参数需要满足什么条件呢?
感谢您的帮助。
实际上 Frame.Navigate("Hello world")
没有问题。
对于可以设置为 content
参数的内容没有限制。
来自 WPF Unleashed 关于 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. For example, properties that would normally be inherited down the element tree stop when they reach theFrame
. In many respects, WPFFrame
s act like frames in HTML.
所以它只是另一个内容控件,它将其内容与应用程序的其余部分分开(通过不继承属性)并提供内置导航。