This is a migrated thread and some comments may be shown as answers.

GridViewComboBoxColumn ItemsSource Binding

1 Answer 232 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
newbie asked on 14 Feb 2011, 06:05 PM
I am trying to do something extremely simple.
I am trying to populate a GridViewComboBoxColumn with a list of numbers ranging from 1 - 16.
This is what I have so far:

<Window x:Class="Login"
        Title="Login" Height="768" Width="1024" xmlns:telerik="">
        <Style TargetType="Label">
            <Setter Property="Width" Value="100"></Setter>
        <Style TargetType="TextBox">
            <Setter Property="Width" Value="100"></Setter>
        <myNamespace:TestUser x:Key="testUser"/ >
        <x:Array x:Key="PortValues" Type="sys:Int32">
    <DockPanel DataContext="{Binding Source={StaticResource testUser}}">
        <StackPanel DockPanel.Dock="Top" VerticalAlignment="Stretch" HorizontalAlignment="Center">
           <telerik:RadGridView Name="RadGridView1" ItemsSource="{Binding FooBars}">
                       ItemsSource="{Binding Source={StaticResource PortValues}}" />

This is my "TestUser" and "FooBar" classes that I am using for testing:

Imports System.ComponentModel
Imports System.Collections.ObjectModel
Public Class TestUser
    Private _fooBars As ObservableCollection(Of FooBar)
    Public Property FooBars As ObservableCollection(Of FooBar)
            Return _fooBars
        End Get
        Set(ByVal value As ObservableCollection(Of FooBar))
            _fooBars = value
        End Set
    End Property
    Public Sub New()
        _fooBars = New ObservableCollection(Of FooBar)
        For i As Integer = 0 To 10
            _fooBars.Add(New FooBar("FooBar" + i.ToString, i))
    End Sub
End Class
Public Class FooBar
    Public Property Value As Integer
    Public Property Name As String
    Public Sub New(ByVal name As String, ByVal value As Integer)
        Me.Value = value
        Me.Name = name
    End Sub
End Class

For some reason I cannot get the GridViewComboBoxColumn to populate with the "PortValues" (I can't even get it to appear).
What am I doing wrong?!?!

Thanks a lot for your help!


1 Answer, 1 is accepted

Sort by
Telerik team
answered on 17 Feb 2011, 04:06 PM
Hi newbie,

Please take another look at our online documentation and demos for a reference on how you may use the GridViewComboBoxColumn. You need to expose the appropriate properties and use them through DataMemberBinding, SelectedValueMemberPath, DisplayMemberPath. So, for example, you may take a look on the implementation of the GridViewComboBoxColumn with Enum ItemsSource. 

All the best,
the Telerik team
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question