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
(1)
11,583 times
Add to favorites
2/1/2011
E-mail Twitter del.icio.us Digg Facebook
Imports System
Imports System.Windows

Public Class MainWindow
    Inherits Window

    Public Sub New()
        Me.InitializeComponent()
        Me.skinComboBox.Items.Add("Blue")
        Me.skinComboBox.Items.Add("Yellow")
        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
        window.Show()
    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