wpf 中的继承NavigationWindow简单问题

malewade 2016-10-12 11:25:29
请问一下在哪继承到NavigationWindow的?刚开始接触wpf不懂。原来的是继承Window,改成NavigationWindow报错
...全文
140 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
malewade 2016-10-12
  • 打赏
  • 举报
回复
引用 4 楼 D56233577 的回复:
修正下,其中XXX是你自己的程序集名。 <NavigationWindow x:Class="XXX.MainWindow" 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:local="clr-namespace:XXX" mc:Ignorable="d" Title="MainWindow" Height="350" Width="525"> </NavigationWindow>
谢谢!
D56233577 2016-10-12
  • 打赏
  • 举报
回复
修正下,其中XXX是你自己的程序集名。 <NavigationWindow x:Class="XXX.MainWindow" 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:local="clr-namespace:XXX" mc:Ignorable="d" Title="MainWindow" Height="350" Width="525"> </NavigationWindow>
D56233577 2016-10-12
  • 打赏
  • 举报
回复
引用 2 楼 malewade 的回复:
[quote=引用 1 楼 D56233577 的回复:] 注意看你的代码,这个类是分部类,所以XAML中的Window也要改成NavigationWindow。
它原本创建时是public partial class MainWindow : Window[/quote] 你这个MainWindow是分部类,他由两个物理文件组成,MainWindow.xaml和MainWindow.xaml.cs, 要让MainWindow继承NavigationWindow而不是Window,两个文件都要改。 MainWindow.xaml.cs修改如下: public partial class MainWindow : NavigationWindow MainWindow.xaml修改如下: <NavigationWindow x:Class="XXX.MainWindow" 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:local="clr-namespace:TestWPF" mc:Ignorable="d" Title="MainWindow" Height="350" Width="525"> </NavigationWindow>
malewade 2016-10-12
  • 打赏
  • 举报
回复
引用 1 楼 D56233577 的回复:
注意看你的代码,这个类是分部类,所以XAML中的Window也要改成NavigationWindow。
它原本创建时是public partial class MainWindow : Window
D56233577 2016-10-12
  • 打赏
  • 举报
回复
注意看你的代码,这个类是分部类,所以XAML中的Window也要改成NavigationWindow。

110,571

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧