Skinned Application Sample

This sample illustrates how to implement an application that supports dynamically-swappable skins. Building the Sample Install the Windows Software Development Kit (SDK) and open its build environment command window.

5 Star
11,585 times
Add to favorites
E-mail Twitter Digg Facebook
Imports System
Imports System.Windows

Public Class MainWindow
    Inherits Window

    Public Sub New()
        Me.skinComboBox.SelectedIndex = 0
        Application.Current.Resources = DirectCast(Application.Current.Properties.Item("Blue"), ResourceDictionary)
        AddHandler Me.skinComboBox.SelectionChanged, New SelectionChangedEventHandler(AddressOf Me.skinComboBox_SelectionChanged)
    End Sub

    Private Sub newChildWindowButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
        Dim window As ChildWindow = New ChildWindow
    End Sub

    Private Sub skinComboBox_SelectionChanged(ByVal sender As Object, ByVal e As SelectionChangedEventArgs)
        Dim skin As String = CStr(e.AddedItems.Item(0))
        Application.Current.Resources = DirectCast(Application.Current.Properties.Item(skin), ResourceDictionary)
    End Sub
End Class