我使用一个共享的资源字典定义默认的样式,并具有在Visual Studio 2008中使用XAML设计主要冲突中的关键不能为空出现的所有尝试,以显示XAML设计视图。
字典合并到App.xaml中(供所有的窗口一起使用),并具有许多样式设置控件的缺省值,所以它们被定义为如下所示不用钥匙 。 如果添加X:关键属性的样式,他们不再默认应用。 我不希望有明确的把风格条款上的每个控件,但它看起来像我可能会。
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Key="windowStyle" TargetType="{x:Type Window}">
<Setter Property="Background" Value="LightGray" />
</Style>
<Style TargetType="{x:Type TextBox}">
<Setter Property="Background" Value="AliceBlue" />
<Setter Property="Height" Value="23" />
</Style>
</ResourceDictionary>
与堆栈完整的异常错误信息:
Key cannot be null.
Parameter name: key
at System.Collections.Hashtable.get_Item(Object key)
at MS.Internal.Xaml.AssemblyNode.For(Assembly assembly, Boolean includeInternal)
at MS.Internal.Xaml.ReflectionProjectNode.LoadAssembly(AssemblyName name, Boolean includeInternal)
at MS.Internal.Xaml.ReflectionProjectNode.BuildAssemblies()
at MS.Internal.Xaml.ReflectionProjectNode.BuildSubsumption()
at MS.Internal.Xaml.ReflectionProjectNode.SubsumingNamespace(Identifier identifier)
at MS.Internal.Xaml.XmlElement.BuildScope(PrefixScope parentScope, IParseContext context)
at MS.Internal.Xaml.XmlElement.FindElementType(PrefixScope parentScope, IParseContext context)
at MS.Internal.DocumentTrees.Markup.XamlSourceDocument.get_RootType()
at Microsoft.Windows.Design.Documents.Trees.MarkupDocumentTreeManager.get_RootType()
at Microsoft.Windows.Design.Documents.MarkupDocumentManager.CalculateLoadErrorState()
at Microsoft.Windows.Design.Documents.MarkupDocumentManager.get_LoadState()
at MS.Internal.Host.PersistenceSubsystem.Load()
at MS.Internal.Host.Designer.Load()
at MS.Internal.Designer.VSDesigner.Load()
at MS.Internal.Designer.VSIsolatedDesigner.VSIsolatedView.Load()
at MS.Internal.Designer.VSIsolatedDesigner.VSIsolatedDesignerFactory.Load(IsolatedView view)
at MS.Internal.Host.Isolation.IsolatedDesigner.BootstrapProxy.LoadDesigner(IsolatedDesignerFactory factory, IsolatedView view)
at MS.Internal.Host.Isolation.IsolatedDesigner.BootstrapProxy.LoadDesigner(IsolatedDesignerFactory factory, IsolatedView view)
at MS.Internal.Host.Isolation.IsolatedDesigner.Load()
at MS.Internal.Designer.DesignerPane.LoadDesignerView()