【问题标题】:Error in application scoped style in WPFWPF 中的应用程序范围样式错误
【发布时间】:2014-04-09 15:40:49
【问题描述】:

我只想创建应用程序定义Style:

<Application x:Class="Customer_UI.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="MainWindow.xaml">

    <Application.Resources>
        <style>
        </style>
    </Application.Resources>
</Application>

ERROR: style is not supported in a Windows Presentation Foundation (WPF) project

【问题讨论】:

  • 是Style 不是style

标签: wpf xaml app.xaml


【解决方案1】:

首先,尝试像这样编写Style 标签:&lt;Style ... /&gt;。其次,您必须为您的样式添加TargetType 或Key,因为ResourcesDictionary 它是一个字典,没有键就不可能有元素。在这种情况下,Key 是一个散列,是未排序字典所需要的。

例子:

<Application.Resources>
    <Style TargetType="{x:Type FrameworkElement}">

    </Style>
</Application.Resources>

有关更多信息,请参阅:

MSDN: Styling and Templating

【讨论】:

  • 是的,我的字母大小写错误,ty
【解决方案2】:
<Application x:Class="Customer_UI.App"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         StartupUri="MainWindow.xaml">
    <Application.Resources>
       <Style>
       </Style>
    </Application.Resources>
</Application>

【讨论】:

  • 它不起作用,因为 Style 必须设置为 Key 或 TargetType。你可以自己查。
猜你喜欢
  • 1970-01-01
  • 2018-02-24
  • 1970-01-01
  • 2013-12-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-03-04
相关资源
最近更新 更多