继承自WPF中的Base页面 [英] inheriting from a Base page in WPF
问题描述
我有一些代码,我不断在WPF页面中的页面后面重复代码。我希望有一个BasePage来继承它们,以简化添加这些函数的过程。我创建了一个名为MMMBasePage的基类,它就像继承自Page的C#类一样。在后面的代码我已经用第二个替换了第一个。
公共部分类主页:Page
公共部分课程主页:MMSBasePage
在XAML中我似乎做错了什么但是至于我可以告诉我做得对。
< src:MMSBasePage x:Class =MMS.Home
xmlns: src =clr-namespace:MMS
xmlns =http://schemas.microsoft.com/winfx/2006/xaml/presentation
xmlns:x =http://schemas.microsoft .com / winfx / 2006 / xaml
xmlns:mc =http://schemas.openxmlformats.org/markup-compatibility/2006
xmlns:d =http://schemas.microsoft .com / expression / blend / 2008
xmlns:uc =clr-namespace:MMS.UserControls
xmlns:filter =clr-namespace:DataGridFilterLibrary; assembly = DataGridFilterLibrary
mc :Ignorable =d
d:DesignHeight =600d:DesignWidth =1000
Title =HomeLoaded =Page_Loaded>
构建后,它以错误开始
XML中不存在属性'Title' namespace'clr-namespace:MMS'。第12行位置7.
没关系。通过我正在经历的所有不同迭代,最后一个我忘了将:Page放回基类。卫生署!无论如何,谢谢你的回答。
我没有看到我自己解决了这个问题。按照之前的说法,我在上一轮忘了从Page继承我的MMSBasePage。 BLOCKQUOTE>
I have some code that I keep repeating in different code behind pages in my WPF Pages. I want to have a BasePage to inherit them from in order to simplify the process of adding these functions in. I have created a base class called MMMBasePage which is just as C# class that inherits from Page. In the code behind I have replace the first with the second.
public partial class Home : Page public partial class Home : MMSBasePage
In the XAML I seem to be doing something wrong but as far as I can tell I did it correctly.
<src:MMSBasePage x:Class="MMS.Home" xmlns:src="clr-namespace:MMS" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:uc="clr-namespace:MMS.UserControls" xmlns:filter="clr-namespace:DataGridFilterLibrary;assembly=DataGridFilterLibrary" mc:Ignorable="d" d:DesignHeight="600" d:DesignWidth="1000" Title="Home" Loaded="Page_Loaded">
After a build it starts with the error
"A property 'Title' does not exist in XML namespace 'clr-namespace:MMS'. Line 12 Position 7.解决方案Never mind. With all the different iterations I was going through, this last one I forgot to put the : Page back into the base class. Doh! Thanks for looking anyway.
I didn't see the "I've solved this myself button. As stated previously, I forgot in the last round to inherit my MMSBasePage from Page.
这篇关于继承自WPF中的Base页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!