In this post, we’ll review some of the more advanced capabilities of DevExpress Smart Tags: including the ability to quickly set an Application Theme or DataContext, easy toggling between Window styles, and more.
Application Theme and Data Context
DevExpress Smart Tags provide special editors for root controls (Window/UserControl) to quickly assign a ViewModel to a data context or set an application-wide theme.
DataContext
If you set the DataContext property, the DevExpress Smart Tag will analyze the modified object. If that object’s type happens to be public, non-nested, unsealed, and also…
- Has a POCOViewModel attribute or implements the IPOCOViewModel interface
- Doesn’t implement the INotifyPropertyChanged interface and there are no properties of the ICommand type
... then the Smart Tag treats the underlying object as a POCO object, meaning its DataContext property is set through a ViewModelSource class.
1: DataContext="{dxmvvm:ViewModelSource Type={x:Type ViewModel:MainViewModel}}"
ApplicationTheme
The ApplicationTheme property applies a single theme (DeepBlue by default) to the entire application at runtime and in Visual Studio.
When you apply a theme, the DevExpress Smart Tag automatically adds the following code to your application:
App.config file (DevExpress generated code preserves the theme between sessions):
1:<?xmlversion="1.0"encoding="utf-8"?>
2:<configuration>
3:<configSections>
4:<sectionGroupname="userSettings" ... >
5:<sectionname="DXThemeManager" ... />
6:</sectionGroup>
7:</configSections>
8:<userSettings>
9:<DXThemeManager>
10:<settingname="ApplicationThemeName"serializeAs="String">
11:<value>Office2013</value>
12:</setting>
13:</DXThemeManager>
14:</userSettings>
15:</configuration>
App.xaml (DevExpress generated XAML applies the theme set in the App.config):
1:<Applicationx:Class="DXDesignTime.App"
2:xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3:xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4:StartupUri="MainWindow.xaml"
5:Startup="OnAppStartup_UpdateThemeName">
6:<Application.Resources>
7:
8:</Application.Resources>
9:</Application>
App.xaml.cs
1:publicpartialclass App : Application {
2:privatevoid OnAppStartup_UpdateThemeName(object sender, StartupEventArgs e) {
3: DevExpress.Xpf.Core.ApplicationThemeHelper.UpdateApplicationThemeName();
4: }
5: }
Image Gallery
You can assign a Control Glyph directly from its Smart Tag. An icon list of choices can be populated from images in your solution or the DevExpress.Images.v14.2.dll assembly. The DevExpress.Images.v14.2.dll assembly contains common images referenced across a wide range of DevExpress controls. To access the complete icon list, press the button beside the Glyph or LargeGlyph property.
The following properties will use an Image Gallery to present their available icons sets: Image.Source, AppBarButton.Glyph, TileBarItem.TileGlyph, NavigationBarItem.Glyph, NavButton.Glyph, BarItem.Glyph, BarItem.LargeGlyph, ImageEdit.Source, Window.Icon, NavBarGroup.ImageSource, NavBarItem.ImageSource, RibbonPageGroup.Glyph.
Convert To DXWindow or DXRibbonWindow
By clicking the Smart Tag’s Convert to DXWindow or Convert to DXRibbonWindow options (both are available when a Window is selected), you can easily convert a Window to a DXWindow or DXRibbonWindow with a single action.
The Smart Tag automatically handles the generation of the necessary XAML and C#.