GridViewComboBoxColumn Binding

0 Answers 21 Views
ComboBox GridView
Lou
Top achievements
Rank 1
Lou asked on 13 May 2021, 11:06 PM

I have a form with a RadGrid control that has its ItemSource set to a collection in my View Model, and it all works

I need to add a GridViewComboBoxColum  to the Grid.   The source will be another collection in the same View Model.

Sounds simple, right?   But I can’t get the ComboBox to appear.

For the examples below:

_vm is a public window variable that is a reference to my View Model.
valuestatus is the collection of values that I want to display in the dropdown.

WL_Dashboard is the class type of the list that is set in theitem source of the grid.

 

<telerik:GridViewComboBoxColumn Name="ValStatusColumn" Header="Val.Status"
   SelectedValueMemberPath
="{Binding Path=ValidationStatus, Mode=TwoWay}"
   IsReadOnly="False"
   HeaderCellStyle="{StaticResource BlueHeaderCellStyle}"
   ItemsSource="{Binding _vm.valuestatus}"
   DisplayMemberPath="valstatus">

</telerik:GridViewComboBoxColumn>

 

 

This does not generate an exception or an error in the output window – but the dropdown does not display

 

If I replace ItemsSource with ItemSourceBinding:

it generates a bunch of errors in the output window and the dropdown does not display:

System.Windows.Data Error: 40 : BindingExpression path error: '_vm' property not found on 'object' ''WL_Dashboard' (HashCode=55939488)'. BindingExpression:Path=_vm._valuestatus; DataItem='WL_Dashboard' (HashCode=55939488); target element is 'RadComboBox' (Name=''); target property is 'ItemsSource' (type 'IEnumerable')

 

The documentation doesn't help me much because there is no itemsSource set on the grid.  It sounds like if use ItemSourceBinding that I need to override the WL_Dashboard setting on the grid for this column - but how?

 

Any idea what I'm doing wrong?  Gotta be something simple that I'm missing here...

 

Thanks in advance for any assistance you can provide.
Lou

Martin Ivanov
Telerik team
commented on 17 May 2021, 10:27 AM

The binding seems correct, however, note that in order for the data binding to get evaluated properly, the bound property of the view model should be a property (not a field) and also it should have public getter and/or setter. If "_vm._valuestatus" is not defined as a property, the binding won't work. Double check this on your side and see if this helps. If not, can you share few additional code snippets showing your models?

No answers yet. Maybe you can help?

Tags
ComboBox GridView
Asked by
Lou
Top achievements
Rank 1
Share this question
or