Hi
I have been trying to get your DataGridComboBox working correctly in a RadDataGrid when using the default external editor (UserEditMode="External").
To help illustrate my point I have amended one of your DataGridUWP examples with a simple combobox binding.
I have used different methods of binding with differing results and have commented the example code below.
I seem to be able to either get the data in the grid or in the edit combobox, but can never get the correct item to be selected in the combobox on edit.
Many thanks.
Paul
Code follows:
<----------------------------------xaml-------------------------------
<
Page
x:Class
=
"DataGridUWP.MainPage"
xmlns:local
=
"using:DataGridUWP"
xmlns:telerikgrid
=
"using:Telerik.UI.Xaml.Controls.Grid"
mc:Ignorable
=
"d"
>
<
Page.Resources
>
<
CollectionViewSource
x:Key
=
"options"
Source
=
"{x:Bind cbOptions}"
/>
</
Page.Resources
>
<
Grid
Background
=
"{ThemeResource ApplicationPageBackgroundThemeBrush}"
>
<
telerikgrid:RadDataGrid
ItemsSource
=
"{x:Bind data}"
x:Name
=
"dataGrid"
UserEditMode
=
"External"
AutoGenerateColumns
=
"False"
>
<
telerikgrid:RadDataGrid.Columns
>
<
telerikgrid:DataGridTextColumn
PropertyName
=
"Name"
/>
<!--Displays in grid. Doesn't display items in drop down-->
<
telerikgrid:DataGridComboBoxColumn
PropertyName
=
"Col1"
x:Name
=
"Col1"
ItemsSource
=
"{Binding Source={StaticResource options}}"
DisplayMemberPath
=
"Name"
/>
<!--Displays in grid. Doesn't display items in drop down-->
<
telerikgrid:DataGridComboBoxColumn
PropertyName
=
"Col2"
x:Name
=
"Col2"
ItemsSource
=
"{Binding cbOptions}"
DisplayMemberPath
=
"Name"
/>
<!--Displays in grid. Displays items in drop down but empty selection-->
<
telerikgrid:DataGridComboBoxColumn
ItemsSource
=
"{x:Bind cbOptions}"
PropertyName
=
"Col3"
x:Name
=
"Col3"
DisplayMemberPath
=
"Name"
/>
<!--Doesn't display correctly in grid. Displays items in drop down, but only with default selected-->
<
telerikgrid:DataGridComboBoxColumn
ItemsSource
=
"{x:Bind cbOptions}"
PropertyName
=
"Col4"
x:Name
=
"Col4"
DisplayMemberPath
=
"Name"
SelectedValuePath
=
"Col4"
/>
</
telerikgrid:RadDataGrid.Columns
>
</
telerikgrid:RadDataGrid
>
</
Grid
>
</
Page
>
<-----------------------------------------cs---------------------------------------------
using
System;
using
System.Collections.Generic;
using
System.Collections.ObjectModel;
using
System.IO;
using
System.Linq;
using
System.Runtime.InteropServices.WindowsRuntime;
using
Windows.Foundation;
using
Windows.Foundation.Collections;
using
Windows.UI.Xaml;
using
Windows.UI.Xaml.Controls;
using
Windows.UI.Xaml.Controls.Primitives;
using
Windows.UI.Xaml.Data;
using
Windows.UI.Xaml.Input;
using
Windows.UI.Xaml.Media;
using
Windows.UI.Xaml.Navigation;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
namespace
DataGridUWP
{
public
sealed
partial
class
MainPage : Page
{
public
ObservableCollection<cbOption> cbOptions {
get
;
set
; }
public
List<Data> data {
get
;
set
; }
public
MainPage()
{
this
.InitializeComponent();
this
.cbOptions =
new
ObservableCollection<cbOption>()
{
new
cbOption(){ Id = 1, Name =
"Option1"
},
new
cbOption(){ Id = 2, Name =
"Option2"
}
};
this
.data =
new
List<Data>()
{
new
Data() { Name =
"Row1"
, Col1 =
new
cbOption(){Id=1,Name=
"Option1"
},Col2 =
new
cbOption(){Id=2,Name=
"Option2"
},Col3 =
new
cbOption(){Id=1,Name=
"Option1"
},Col4 =
new
cbOption(){Id=2,Name=
"Option2"
} },
new
Data() { Name =
"Row2"
, Col1 =
new
cbOption(){Id=2,Name=
"Option2"
},Col2 =
new
cbOption(){Id=2,Name=
"Option2"
},Col3 =
new
cbOption(){Id=2,Name=
"Option2"
},Col4 =
new
cbOption(){Id=1,Name=
"Option1"
} },
new
Data() { Name =
"Row3"
, Col1 =
new
cbOption(){Id=2,Name=
"Option2"
},Col2 =
new
cbOption(){Id=2,Name=
"Option2"
},Col3 =
new
cbOption(){Id=2,Name=
"Option2"
},Col4 =
new
cbOption(){Id=2,Name=
"Option2"
} },
};
}
}
public
class
Data
{
public
string
Name {
get
;
set
; }
public
cbOption Col1 {
get
;
set
; }
public
cbOption Col2 {
get
;
set
; }
public
cbOption Col3 {
get
;
set
; }
public
cbOption Col4 {
get
;
set
; }
}
public
class
cbOption
{
public
int
Id {
get
;
set
; }
public
string
Name {
get
;
set
; }
}
}