是否可以从 Silverlight 的 System.Windows.Controls.Page 继承?
我想创建 Silverlight 导航框架的 Page 类的后代,以便我可以在所有页面上执行通用导航代码,但我不知道如何执行此操作。当我创建后代类时,如何从 XAML 文件中引用它?
他们目前有“navigation:page”标签,那么我如何用“mypage”替换它呢?我需要为我的后代添加注释吗?
示例:
我目前有以下内容:
<navigation:Page x:Class="Views.About"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"
Title="About"
Style="{StaticResource PageStyle}">
...
</navigation:Page>
相反,我想要(给定一个类 MyOwnPage :System.Windows.Controls.Page)
<MyOwnPage ...>
...
</MyOwnPage>
I would like to create a descendant of the Silverlight Navigation Framework's Page class, so I can perform common navigation code on all of my pages, but I can't figure out how to do this. When I create a descendant class, how do I reference that from my XAML files?
They currently have the "navigation:page" tag, so how do I replace that with "mypage" instead? Is there an annotation I need to add to my descendant?
Example:
I currently have the following:
<navigation:Page x:Class="Views.About"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"
Title="About"
Style="{StaticResource PageStyle}">
...
</navigation:Page>
Instead, I would like (given a class MyOwnPage : System.Windows.Controls.Page)
<MyOwnPage ...>
...
</MyOwnPage>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我得到了它。使用上面的示例,您需要在开始标记中引用该子组件,如下所示:
然后将根元素声明为
I got it. Using the example above, you need to reference that subassembly in the opening tag, like so:
and then declare the root element as