
This significantly improves startup time for forms with editors bound to large source collections. Data editors traverse through source items until the selected item is found. ComboBo圎dit, LookUpEdit, ListBo圎dit), no longer process the entire source collection at startup.
DEVEXPRESS WPF THEMES SERIES
DEVEXPRESS WPF THEMES CODE
Seeing that the code to open the options window is trivial (call ShowDialog() when I select Tools -> Options from the menu), I’ll only talk about the code in the options window. On the left, you can see the second theme, and on the right, you can see the options window. When the application starts, no theme is applied, but you can change this easily. The main window will contain the list box control that will be styled, and the second window will let you choose the theme to apply. You can now add the assembly to the reserved folder in the main application.
DEVEXPRESS WPF THEMES DOWNLOAD
Or you can download the sample for this article.Īfter you have all the styles for your theme, you need to compile the assembly and you’re done. You can see what the first theme looks like by viewing my previous article at: The only thing that is different is the styles that are applied. I won’t present the code for the second theme because it is almost identical. Public partial class ScrollBarDictionary: ResourceDictionary The code is for the ListBoxStyle.xaml dictionary. In order to link the resource dictionary file to the code-behind file, you have to do a few things.įirst, you have to set the x:Class attribute in the resource dictionary to the name you want the class to have. This code-behind file will be very useful when loading resources. This can be seen in the image below:Īs you can see from the image above, every resource dictionary has an associated code-behind file. This assembly will contain one or more resource dictionaries that will contain the resources for the theme (brushes, animations, control templates, styles etc.). Like I said in the beginning, themes will be represented by an assembly. I will present those two projects first, and at the end, I’ll show the reflection code that loads these assemblies. The other two projects show how a theme should be built in order to be properly loaded. One is the main project that uses the themes. The application solution has three projects. All that matters is that the templates be applied using styles that apply to controls by default (styles without a resource key). The number of files doesn’t matter, the resource key names don’t matter. All the assembly needs to have is the resource dictionaries that represent the themes. These resource dictionaries also have a code-behind class attached to them so that I can access them in code. The themes are represented by resource dictionaries. When the application starts, I load the assemblies using Reflection, as will be seen later. If the user wants a new theme, all he/she needs to do is to add a new assembly to that folder. What I mean by this is that I have a dedicated folder in the application where all the themes reside. In order for this to happen, I chose a pluggable architecture. This code is intended to help an application developer change or add styles to his/her applications without recompiling it. This is a continuation of another article I wrote that presented a Blend like style for a scrollbar. This article presents a sample application that uses a combo box to change a WPF theme at runtime.
