<Controls1:GridViewComboBoxColumn Header="Accomplishment Category"
ItemsSource="{Binding AccomplishmentCategoryList}"
DataMemberBinding="{Binding AccomplishmentCategoryValue}"
SelectedValueMemberPath="{Binding AccomplishmentCategoryValue}">
</Controls1:GridViewComboBoxColumn>
I am able to get my grid to display the results for its own itemSource.
<Controls1:RadGridView x:Name="Accomplishments" Grid.Row="1" CanUserInsertRows="True"
ShowInsertRow="True" CanUserDeleteRows="True" RowIndicatorVisibility="Visible"
IsReadOnly="False" ItemsSource="{Binding AccomplishmentResults, Mode=TwoWay}">
The AccomplishmentResults collection binds perfectly. my issue is the combobox does not display anything until you actually click on the column that contains the combobox control. so that column looks empty, when you click on the column the results are displayed, when you click again you get the combobox that will show the items in that collection..if you select anything other than that column those values disappear and are empty again. if you select the row they remain empty..it is only when the column is selected that the values appear.
10 Answers, 1 is accepted
You may take a look at this troubleshooting article for a reference.
Maya
the Telerik team
<Controls1:GridViewComboBoxColumn Header="Accomplishment Category" ItemsSource="{Binding AccomplishmentCategoryList}" DataMemberBinding="{Binding AccomplishmentCategoryValue}" SelectedValueMemberPath="{Binding AccomplishmentCategoryValue}"></Controls1:GridViewComboBoxColumn>
and the second solution wont work as we are using an MVVM pattern and we dont want to set anything in the code behind.
May you try to define your ViewModel in the Resource section of the UserControl and use it as a StaticResource afterwards ?
<
UserControl.Resources
>
<
local:MainPageViewModel
x:Key
=
"mainPageViewModel"
/>
</
UserControl.Resources
>
...
<
telerik:GridViewComboBoxColumn
Header
=
"Category"
DataMemberBinding
=
"{Binding CategoryID}"
ItemsSource
=
"{Binding Path=Categories, Source={StaticResource mainPageViewModel}}"
DisplayMemberPath
=
"CategoryName"
SelectedValueMemberPath
=
"CategoryID"
/>
All the best,
Maya
the Telerik team
thanks - George
Basically, the behavior you experience is due to the difference between the DataContext of the row (which is the item itself) and the one of the column. Consequently, unless being set explicitly, the data for the column will be available on getting focus. That is why the two possible approaches are either to set the ItemsSource in the code-behind or through the Source property of the binding with a StaticResource.
Yet another possibility may be to use the ItemsSourceBinding of the GridViewComboBoxColumn. However, in this case you will have to expose a new property in our business object that holds the items for the column.
Maya
the Telerik team
Allow me ask .... Does setting ItemsSourceBinding solve the issue.
I mean I export a property form my VM that holds the items, but is doesn't show up unless I add that property to the page resource.
Is this what you meant by using ItemsSourceBinding the or I understood that ...
Regards
If you want to use the ItemsSourceBinding, you have to expose a property in your business object that will contain the source for the GridViewComboBoxColumn. So, let us say that you have an object of type Person that will be the data item for the grid. You may add a property
- ObservableCollection<Country> Countries {get;set;}
Afterwards, you may set the ItemsSourceBidning directly to "Countries" - ItemsSourceBingind={Binding Countries}".
Maya
the Telerik team
I assure you that this scenario is not working because:
I have two QDSCV to hold my RadGridView source and the GridViewComboBoxColumn defined at my VM if I use the following ItemsSourceBinding="{Binding AccountCollection}" for the GridViewComboBoxColumn it doesn't show up the data unless I use the DataContextProxy as a resource in my view model.
Regards
I am sending you a sample project illustrating the usage of ItemsSourceBinding. Please take a look at it and let me know whether you have implement it similarly or you have additional settings or requirements.
Maya
the Telerik team
As I said before you can't have the binding works without this part in the xaml:
<
UserControl.Resources
>
<
my:MyViewModel
x:Key
=
"MyViewModel"
/>
</
UserControl.Resources
>
Which means that you need to have the ViewModel as a resource in XAML.or to have somthing like DataContextProxy.
Thanks