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

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

, 5 Apr 2008
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.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Documents
Imports System.Windows.Media
Imports System.Windows.Shapes
Imports System.Collections.ObjectModel
Imports System.Collections.Generic

#Region "Inner data classes"
Public Class League
    Private m_Name As String
    Public Property Name() As String
        Get
            Return m_Name
        End Get
        Private Set(ByVal value As String)
            m_Name = value
        End Set
    End Property

    Private m_Divisions As List(Of Division)
    Public Property Divisions() As List(Of Division)
        Get
            Return m_Divisions
        End Get
        Private Set(ByVal value As List(Of Division))
            m_Divisions = value
        End Set
    End Property

    Public Sub New(ByVal newname As String)
        Name = newname
        Divisions = New List(Of Division)()
    End Sub
End Class

Public Class Division
    Private m_Name As String
    Public Property Name() As String
        Get
            Return m_Name
        End Get
        Private Set(ByVal value As String)
            m_Name = value
        End Set
    End Property
    Private m_Teams As List(Of Team)
    Public Property Teams() As List(Of Team)
        Get
            Return m_Teams
        End Get
        Private Set(ByVal value As List(Of Team))
            m_Teams = value
        End Set
    End Property

    Public Sub New(ByVal newname As String)
        Name = newname
        Teams = New List(Of Team)()
    End Sub
End Class



Public Class Team
    Private m_Name As String
    Public Property Name() As String
        Get
            Return m_Name
        End Get
        Private Set(ByVal value As String)
            m_Name = value
        End Set
    End Property

    Public Sub New(ByVal newname As String)
        Name = newname
    End Sub
End Class
#End Region

#Region "LeagueList"

''' <summary> 
''' Provides a simple LeagueList, holding dummy 
''' data to demonstrate binding to Hierarchical 
''' data structures 
''' </summary> 
Public Class LeagueList
    Inherits List(Of League)
    Public Sub New()
        Dim l As League
        Dim d As Division
        l = New League("League A")
        Add(l)
        d = New Division("Division A")
        l.Divisions.Add(d)
        d.Teams.Add(New Team("Team I"))
        d.Teams.Add(New Team("Team II"))
        d.Teams.Add(New Team("Team III"))
        d.Teams.Add(New Team("Team IV"))
        d.Teams.Add(New Team("Team V"))
        d = New Division("Division B")
        l.Divisions.Add(d)
        d.Teams.Add(New Team("Team Blue"))
        d.Teams.Add(New Team("Team Red"))
        d.Teams.Add(New Team("Team Yellow"))
        d.Teams.Add(New Team("Team Green"))
        d.Teams.Add(New Team("Team Orange"))
        d = New Division("Division C")
        l.Divisions.Add(d)
        d.Teams.Add(New Team("Team East"))
        d.Teams.Add(New Team("Team West"))
        d.Teams.Add(New Team("Team North"))
        d.Teams.Add(New Team("Team South"))
        l = New League("League B")
        Add(l)
        d = New Division("Division A")
        l.Divisions.Add(d)
        d.Teams.Add(New Team("Team 1"))
        d.Teams.Add(New Team("Team 2"))
        d.Teams.Add(New Team("Team 3"))
        d.Teams.Add(New Team("Team 4"))
        d.Teams.Add(New Team("Team 5"))
        d = New Division("Division B")
        l.Divisions.Add(d)
        d.Teams.Add(New Team("Team Diamond"))
        d.Teams.Add(New Team("Team Heart"))
        d.Teams.Add(New Team("Team Club"))
        d.Teams.Add(New Team("Team Spade"))
        d = New Division("Division C")
        l.Divisions.Add(d)
        d.Teams.Add(New Team("Team Alpha"))
        d.Teams.Add(New Team("Team Beta"))
        d.Teams.Add(New Team("Team Gamma"))
        d.Teams.Add(New Team("Team Delta"))
        d.Teams.Add(New Team("Team Epsilon"))
    End Sub

    Default Public Overloads ReadOnly Property Item(ByVal name As String) As League
        Get
            For Each l As League In Me
                If l.Name = name Then
                    Return l
                End If
            Next

            Return Nothing
        End Get
    End Property
End Class
#End Region

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 | Mobile
Web01 | 2.8.140926.1 | Last Updated 5 Apr 2008
Article Copyright 2008 by Sacha Barber
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid