locked
Problem with themes -- keeping a 'generic' theme with virgin styles RRS feed

  • Question

  • I'm having a problem keeping my 'generic' theme clean when creating several themes for my application.  The generic theme is supposed to be a theme whereby few or no styles are applied except where absolutely necessary, and where the controls all maintain their default appearance.  In most cases, dead-ending the particular style in my generic theme resource dictionaries does the trick--in the presence of no defined theme, WPF falls back on the default control style.  However, in the case of ListBoxes, this is not the case.  If I dead-end the style, then the ListBox is not visible.  If I simply leave out the style in the resource dictionary, leaving the style unresolved for that particular listbox, the same thing happens--it isn't visible.  What is the best way to force that control to use the generic (default) windows/wpf style for that control?

    Here's an example of a dead-ended style in my generic resource dictionary:

    	<!-- CONDITIONS AND MATERIALS LISTBOX STYLE -->
    	<Style x:Key="ListBoxItemOdontogramStyle" TargetType="{x:Type ListBoxItem}">
    	</Style>	
    	<!-- CONDITIONS AND MATERIALS MASTER CONTAINER (LISTBOX) -->
    	<ControlTemplate x:Key="ListBoxOdontogramConditionsContainer" TargetType="{x:Type ListBox}">
    	</ControlTemplate>
    



    Purkiss
    Friday, August 26, 2011 4:44 PM

All replies

  • I'm sorry, I don't think I fully understand what you're asking...

    But here goes my best answer. The best way to force a control to use the default Style is to simply not supply one of your own. If you have a Style with TargetType="ListBox" with no Key then it will be applied by default. Ensure that you don't have any styles like that and it should apply the default Style.

    Friday, September 23, 2011 4:29 PM