Tag: xaml designer

WPF设计器在启动时不运行窗口静态构造函数

当我加载解决方案并且某个窗口有一个打开的设计器选项卡时,则不会执行此窗口静态构造函数。 也许我的结论是错误的(因为我绝对不知道设计师如何加载东西),但这是一个测试用例: 创建新的WPF项目。 创建简单的扩展 public class MyExtension : MarkupExtension { public static bool Test; public override object ProvideValue(IServiceProvider serviceProvider) => Test.ToString(); } 添加到主窗口 和 static MainWindow() { MyExtension.Test = true; } 现在编译它( F6 ), TextBlock应该在设计器中显示True 。 不要关闭设计师窗口。 关闭VS. 启动解决方案(双击sln文件)。 设计器加载窗口后,您将看到TextBlock显示False 。 WTF? 有人可以确认(或者是我的VS 2015错误)? 我真的想知道设计师是如何工作的:如何加载窗口,使用哪些事件/方法等等。似乎没有执行窗口构造函数(非静态函数)(设计时没有发生任何事情),如何是窗口然后创建和显示?

Visual Studio 2015(社区)设计器显示空白Universal App的NullReferenceException

我对此感到有些沮丧,也许有人遇到了类似的问题或者想知道如何修复它。 我升级到Windows 10。 我安装了Visual Studio 2015社区。 我创建了一个新的解决方案,只有一个项目用于空白的通用Windows应用程序。 我正在使用C#。 问题:我试图在设计器中打开MainPage.xaml,但设计器不会加载。 我在设计器窗口中得到NullReferenceException 。 我尝试在Blend中打开它,结果相同。 正如Visual Studio建议的那样,我尝试关闭“选项”菜单中的“在XAML Designer中运行项目代码”function,但它没有帮助。 在设计器中打开其他xaml文件没有问题(WPF,Windows Phone 8或8.1 Universal应用程序都可以正常工作)。 该应用程序在本地计算机上运行,​​在模拟器中,只有设计者才能执行。 欢迎任何建议。 编辑 设计师窗口的例外情况: System.NullReferenceException Object reference not set to an instance of an object. at Microsoft.VisualStudio.DesignTools.Platform.Metadata.MetadataStore.GetTypeConverter(Type type) at Microsoft.VisualStudio.DesignTools.WindowsXamlDesigner.WindowsUIXamlDesignTimeProperties.ResolveImplementation(IPlatformMetadata platformMetadata, DesignTimePropertyId neutralProperty, IType declaringType, PropertyChangedCallback callback) at Microsoft.VisualStudio.DesignTools.WindowsXamlDesigner.WindowsUIXamlDesignTimeProperties.RegisterProperty(IPropertyId neutralPropertyKey, IType declaringType, PropertyChangedCallback callback) at Microsoft.VisualStudio.DesignTools.WindowsXamlDesigner.WindowsUIXamlCommonDesignTimeProperties.Initialize(WindowsUIXamlDesignTimeProperties […]