开发者

Is it possible to descend from Silverlight's System.Windows.Controls.Page?

开发者 https://www.devze.com 2022-12-13 08:59 出处:网络
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 cr

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 descendan开发者_如何学Pythont?

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>


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>
0

精彩评论

暂无评论...
验证码 换一张
取 消