Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6208355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:47:39+00:00 2026-05-24T05:47:39+00:00

I am building some WPF pages in a win forms application. I wish to

  • 0

I am building some WPF pages in a win forms application. I wish to use WPF Themes for my application. Not having an App.xaml (because the project is a win forms project with a WPF ElementHost to show the WPF forms) I added my theme resource dictionary in my form like this:

<UserControl.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/Themes/ExpressionDark.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</UserControl.Resources>

This works for all controls on this form plus some of the other WPF user controls, but there are some user controls where the theme is not functioning. I have tracked down that the affected controls that define their own resources like this:

    <Grid.Resources>
        <Style TargetType="ComboBox">
            <Setter Property="Margin" Value="0 2 5 2" />
        </Style>
    </Grid.Resources>

It doesn’t seem to matter where the resources are located or what is in the resource. Anything in the resource that is not keyed blocks the theme for everything that style targets. I even tried to out-smart it by finding the resource in the dictionary:

<Style TargetType="{x:Type ComboBox}">
    <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
    <Setter Property="SnapsToDevicePixels" Value="true" />
    <Setter Property="Template" Value="{DynamicResource ComboBoxTemplate}" />
</Style>

And modifying my style to look like this:

    <Grid.Resources>
        <Style TargetType="ComboBox">
            <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
            <Setter Property="SnapsToDevicePixels" Value="true" />
            <Setter Property="Template" Value="{DynamicResource ComboBoxTemplate}" />
            <Setter Property="Margin" Value="0 2 5 2" />
        </Style>
    </Grid.Resources>

But that caused my combo boxes to disappear completely!

Is there any way to add resources that blanket target controls and not throw off the theme?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T05:47:40+00:00Added an answer on May 24, 2026 at 5:47 am

    You just need to set the BasedOn property of the Style to the old implicit Style:

    <Grid.Resources>
        <Style x:Key="ComboBoxStyle" 
               TargetType="{x:Type ComboBox}" 
               BasedOn="{StaticResource {x:Type ComboBox}}">
            <Setter Property="Margin" Value="0 2 5 2" />
        </Style>
    
    </Grid.Resources>
    

    edit

    So, if you don’t want to use the resource key on all of your ComboBox’s, you have to take it one step further. I don’t know why WPF / WinForms interop handles implicit styles so poorly, but even if you add an implicit style to the resources here, and set BasedOn="{StaticResource ComboBoxStyle}", you will still lose your template.

    However, if you move the resources to the UserControl, you can then do the implicit style properly:

    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Themes/ExpressionDark.xaml" />
            </ResourceDictionary.MergedDictionaries>
    
            <Style x:Key="ComboBoxStyle" 
                   TargetType="{x:Type ComboBox}"
                   BasedOn="{StaticResource {x:Type ComboBox}}">
                <Setter Property="Margin" Value="0 2 5 2" />
            </Style>
        </ResourceDictionary>
    </UserControl.Resources>
    
    <Grid>
        <Grid.Resources>
            <Style TargetType="{x:Type ComboBox}" 
                       BasedOn="{StaticResource ComboBoxStyle}" />
        </Grid.Resources>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building an application in C# using WPF. How can I bind to some
I'm building some WPF application to manage my time. I'd like to save time
I'm building a WPF application. I'm doing some async communication with the server side,
Im building a wpf app with the composite application block (prism) V2, and Im
I'm looking at building some web user controls with an eye toward re-use, but
Is there a compression API available for use on the iPhone? We're building some
I'm building a python application from some source code I've found Here I've managed
Currently building a WPF app that will run in an environment where the user
Building my first SL MVVM application (Silverlight4 RC) and have some issues i don't
I am building a small wpf app in C#. When a button gets clicked

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.