Imports System.Collections.Generic
Imports System.Linq
Imports System.Net
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Documents
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Media.Animation
Imports System.Windows.Shapes
Imports System.ComponentModel
Imports Telerik.Windows.Controls

Namespace multiColumnCombo_SL
	Public Partial Class MainPage
		Inherits UserControl
		Public Sub New()
			InitializeComponent()

			Dim persons As New List(Of Person)()
			persons.Add(New Person(1, "Carlos"))
			persons.Add(New Person(2, "Hans"))
			persons.Add(New Person(3, "Pierre"))

			Me.RadGridView1.ItemsSource = persons
			DirectCast(Me.RadGridView1.Columns(1), GridViewComboBoxColumn).ItemsSource = GetCountries()
		End Sub

		Private Function GetCountries() As List(Of Country)
			Dim countries As New List(Of Country)()
			countries.Add(New Country(1, InlineAssignHelper(Name, "Spain")))
			countries.Add(New Country(2, InlineAssignHelper(Name, "Germany")))
			countries.Add(New Country(3, InlineAssignHelper(Name, "France")))


			Return countries
		End Function

		Private Function GetCountries2() As List(Of Country)
			Dim countries As New List(Of Country)()
			countries.Add(New Country(1, "Japan"))
			countries.Add(New Country(2, "China"))
			countries.Add(New Country(3, "Korea"))

			Return countries
		End Function

		Private Sub Button_Click(sender As Object, e As RoutedEventArgs)
			DirectCast(Me.RadGridView1.Columns(1), GridViewComboBoxColumn).ItemsSource = GetCountries2()
		End Sub
		Private Shared Function InlineAssignHelper(Of T)(ByRef target As T, value As T) As T
			target = value
			Return value
		End Function
	End Class

	Public Class Country
		Public Sub New(id As Integer, name As String)
			Me.Name = name
			Me.m_id = id
		End Sub

		Private m_id As Integer
		Public Property ID() As Integer
			Get
				Return Me.m_id
			End Get
			Set
				Me.m_id = value
			End Set
		End Property
		Private m_name As String
		Public Property Name() As String
			Get
				Return Me.m_name
			End Get
			Set
				Me.m_name = value
			End Set
		End Property
	End Class

	Public Class Person
		Implements INotifyPropertyChanged
		Public Sub New(countryID As Integer, name As String)
			Me.Name = name
			Me.CountryID = countryID
		End Sub

		Private m_name As String
		Public Property Name() As String
			Get
				Return Me.m_name
			End Get
			Set
				Me.m_name = value
			End Set
		End Property
		Private m_countryID As Integer
		Public Property CountryID() As Integer
			Get
				Return Me.m_countryID
			End Get
			Set
				If Me.m_countryID <> value Then
					Me.m_countryID = value
					Me.OnPropertyChanged("CountryID")
				End If
			End Set
		End Property


		Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged 

		Private Sub OnPropertyChanged([property] As String)
			RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs([property]))
		End Sub

	End Class
End Namespace
