我有一个从自定义窗口继承的WPF窗口。它运行正常,但VS设计器显示它像默认的空窗口。XAML设计器不显示自定义窗口
自定义窗口代码:
using System.Windows;
using System.Windows.Media;
namespace WpfApplication2
{
public class CustomWindow : Window
{
public CustomWindow()
{
Background = new SolidColorBrush(Colors.Red);
}
}
}
MainWindow.xaml
:
<local:CustomWindow x:Class="WpfApplication2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApplication2"
Title="MainWindow" Height="350" Width="525">
</local:CustomWindow>
设计师:
预期结果:
你缺少'的InitializeComponent()' – VVN
没有这样的功能,因为'CustomWindow'类不包含XAML。无论如何,从Windows继承包含XAML标记的类是不可能的。 – Poma
什么版本/构建VS?什么版本的Windows? – Taterhead