是否可以从 Silverlight 的 System.Windows.Controls.Page 继承?

发布于 2024-08-14 04:14:34 字数 922 浏览 1 评论 0原文

我想创建 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谁把谁当真 2024-08-21 04:14:34

我得到了它。使用上面的示例,您需要在开始标记中引用该子组件,如下所示:

xmlns:views="clr-namespace:Views"

然后将根元素声明为

<views:MyOwnPage ...>
...
</views:MyOwnPage>

I got it. Using the example above, you need to reference that subassembly in the opening tag, like so:

xmlns:views="clr-namespace:Views"

and then declare the root element as

<views:MyOwnPage ...>
...
</views:MyOwnPage>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文