0
votes

I am overriding style for combobox in universal app using wpf. Everything works fine on windows 8.1, but on windows phone 8.1 I got error stating that no resources with the key/name ComboBoxThemeMinWidth exists.

<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}" />
...

What am I doing wrong? All I need is different style for combobox, but I can't figure how I can do it for windows phone.

1
does the error happen in designer or after compilation...sometimes restarting of the VisualStudio helpsJozef Cechovsky
after compilation during startup of the appbenderto
Try putting your style in a separate Resource Dictionary file, and use MergedDictionaries in your App.xaml file to reference it.Mike Eason
no change, still getting that error...benderto

1 Answers

0
votes

Ok I solved it. According to this Nested styles in Universal Apps, styles works quite different in WinRT. I solved it by defining styles for windows desktop in its MainPage. For windows phone I put styles in resources of combo box's parent control and use it as static resource in combo box style property. Many properties in styles are also different, but you can find full definitions for controls in C:\Program Files (x86)\Windows Phone Kits\8.1\Include\abi\Xaml\Design\generic.xaml.