【问题标题】:ComboBox style in universal app通用应用程序中的组合框样式
【发布时间】:2015-05-22 12:10:00
【问题描述】:

我正在使用 wpf 覆盖通用应用程序中组合框的样式。在 windows 8.1 上一切正常,但在 windows phone 8.1 上我收到错误消息,指出不存在具有键/名称 ComboBoxThemeMinWidth 的资源。

<Application 
    x:Class="wcc.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:wcc"
    RequestedTheme="Dark">

<Application.Resources>

<Style TargetType="ComboBox">
    <Setter Property="Padding" Value="8,0" />
    <Setter Property="MinWidth" Value="{ThemeResource ComboBoxThemeMinWidth}" />
    <Setter Property="Foreground" Value="{ThemeResource ComboBoxForegroundThemeBrush}" />
...

我做错了什么?我所需要的只是组合框的不同样式,但我不知道如何为 windows phone 做到这一点。

【问题讨论】:

  • 错误是否发生在设计器中或编译后...有时重新启动 VisualStudio 会有所帮助
  • 应用启动时编译后
  • 尝试将您的样式放在单独的资源字典文件中,并在您的 App.xaml 文件中使用 MergedDictionaries 来引用它。
  • 没有变化,仍然出现该错误...

标签: c# wpf combobox win-universal-app


【解决方案1】:

好的,我解决了。根据Nested styles in Universal Apps,样式在 WinRT 中的工作方式完全不同。我通过在其 MainPage 中定义 Windows 桌面的样式来解决它。对于 windows phone,我将样式放在组合框父控件的资源中,并将其用作组合框样式属性中的静态资源。样式中的许多属性也有所不同,但您可以在C:\Program Files (x86)\Windows Phone Kits\8.1\Include\abi\Xaml\Design\generic.xaml 中找到控件的完整定义。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多