Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

WPF: A Beginner's Guide - Part 6 of n

, 5 Apr 2008 CPOL
An introduction into WPF Styles and Templates.
part6_styles_and_templates.zip
Part6_Styles_And_Templates
Styles_And_Templates
Beatriz Costa Planet ListBox
bin
Debug
Styles_And_Templates.exe
Styles_And_Templates.vshost.exe
Styles_And_Templates.vshost.exe.manifest
Data
Images
2moons_2.gif
DataLogo.png
earglobe.gif
jupglobe.gif
marglobe.gif
merglobe.gif
nepglobe.gif
planetx.jpg
plutoch_2.gif
sun.jpg
uraglobe.gif
venglobe.gif
obj
Debug
Bea Costa Planet ListBox
Beatriz Costa Planet ListBox
Templates
TempPE
Properties
Settings.settings
part6_styles_and_templates_vb.zip
Part6_Styles_And_Templates_VB
Part6_Styles_And_Templates_VB
Beatriz Costa Planet ListBox
bin
Debug
Part6_Styles_And_Templates.exe
Part6_Styles_And_Templates.vshost.exe
Part6_Styles_And_Templates.vshost.exe.manifest
Data
Images
2moons_2.gif
DataLogo.png
earglobe.gif
jupglobe.gif
marglobe.gif
merglobe.gif
nepglobe.gif
planetx.jpg
plutoch_2.gif
sun.jpg
uraglobe.gif
venglobe.gif
My Project
MyExtensions
Settings.settings
obj
Debug
Beatriz Costa Planet ListBox
TempPE
Part6_Styles_And_Templates_VB.vbproj.user
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Documents
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Media.Imaging
Imports System.Windows.Navigation
Imports System.Windows.Shapes

''' <summary> 
''' Simply launches the reqested demo window, oh and 
''' also demonstrates the use of a DataTemplate within 
''' the associated DemoLauncherWindow.xaml 
''' </summary> 
Partial Public Class DemoLauncherWindow
    Inherits Window
    ''' <summary> 
    ''' Constructs a new DemoLauncherWindow, and 
    ''' creates a bunch of <see cref="DemoListItem"> 
    ''' DemoListItem</see> items to be used within the 
    ''' contained ListBox 
    ''' </summary> 
    Public Sub New()
        InitializeComponent()

        'Create the demo list items 
        Dim newitem1 As New DemoListItem

        newitem1.DemoName = "Hierarchical Template Example"
        newitem1.WindowName = "HierarchicalDataTemplateWindow.xaml"
        lstDemos.Items.Add(newitem1)

        Dim newitem2 As New DemoListItem
        newitem2.DemoName = "Planets ListBox Template Example"
        newitem2.WindowName = "PlanetsListBoxWindow.xaml"
        lstDemos.Items.Add(newitem2)

        Dim newitem3 As New DemoListItem
        newitem3.DemoName = "Various Control Templates Example"
        newitem3.WindowName = "VariousControlTemplatesWindow.xaml"
        lstDemos.Items.Add(newitem3)


    End Sub

    ''' <summary> 
    ''' Show the demo window requested 
    ''' </summary> 
    Private Sub lstDemos_SelectionChanged(ByVal sender As Object, ByVal e As SelectionChangedEventArgs)
        Dim winName As String = TryCast(lstDemos.SelectedItem, DemoListItem).WindowName
        Dim win As Window = Nothing

        Select Case winName
            Case "HierarchicalDataTemplateWindow.xaml"
                win = New HierarchicalDataTemplateWindow()
                Exit Select
            Case "PlanetsListBoxWindow.xaml"
                win = New PlanetsListBoxWindow()
                Exit Select
            Case "VariousControlTemplatesWindow.xaml"
                win = New VariousControlTemplatesWindow()
                Exit Select

        End Select
        win.Owner = Me
        win.Width = Me.Width
        win.Height = Me.Height
        win.WindowStartupLocation = WindowStartupLocation.CenterOwner
        win.ShowInTaskbar = False
        win.ResizeMode = ResizeMode.NoResize
        win.ShowDialog()
    End Sub
End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Sacha Barber
Software Developer (Senior)
United Kingdom United Kingdom
I currently hold the following qualifications (amongst others, I also studied Music Technology and Electronics, for my sins)
 
- MSc (Passed with distinctions), in Information Technology for E-Commerce
- BSc Hons (1st class) in Computer Science & Artificial Intelligence
 
Both of these at Sussex University UK.
 
Award(s)

I am lucky enough to have won a few awards for Zany Crazy code articles over the years

  • Microsoft C# MVP 2014
  • Codeproject MVP 2014
  • Microsoft C# MVP 2013
  • Codeproject MVP 2013
  • Microsoft C# MVP 2012
  • Codeproject MVP 2012
  • Microsoft C# MVP 2011
  • Codeproject MVP 2011
  • Microsoft C# MVP 2010
  • Codeproject MVP 2010
  • Microsoft C# MVP 2009
  • Codeproject MVP 2009
  • Microsoft C# MVP 2008
  • Codeproject MVP 2008
  • And numerous codeproject awards which you can see over at my blog

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.141220.1 | Last Updated 5 Apr 2008
Article Copyright 2008 by Sacha Barber
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid