I am having problems getting paste from clipboard to work with a GridView that contains a ComboBox column.
I started from the "Classic binding to objects" Telerik demo for the ComboBox column with the addition of a RowNumber column.
If I set up the binding in code-behind (in the Page_Loaded handler) as in the demo then pasting a column of values from Excel works fine, as in the Telerik demo.
However, if I set up the binding in Xaml (necessary for easy mvvm master-details I think?) then there are problems:
1. The values in the grid do not appear until the grid is clicked on.
2. If a new row is inserted (Click to add new item, select from combobox, press Enter), the values in the grid disappear until the grid is clicked on.
3. Pasting a column of values from Excel does not work. Objects are added to the collection but the value is that of the last manually selected value from one of the ComboBoxes.
How do I fix this and have pasting working with Xaml databinding?
I started from the "Classic binding to objects" Telerik demo for the ComboBox column with the addition of a RowNumber column.
If I set up the binding in code-behind (in the Page_Loaded handler) as in the demo then pasting a column of values from Excel works fine, as in the Telerik demo.
MainPageViewModel model = (MainPageViewModel)
this
.DataContext;
// Grid 1. As Telerik demo
GridViewComboBoxColumn comboColumn1 =
new
GridViewComboBoxColumn();
comboColumn1.DataMemberBinding =
new
Binding(
"CountryId"
);
comboColumn1.SelectedValueMemberPath =
"Id"
;
comboColumn1.DisplayMemberPath =
"Name"
;
comboColumn1.ItemsSource = model.AllCountries;
radGridView1.Columns.Add(comboColumn1);
radGridView1.ItemsSource = model.AllLocations;
However, if I set up the binding in Xaml (necessary for easy mvvm master-details I think?) then there are problems:
1. The values in the grid do not appear until the grid is clicked on.
2. If a new row is inserted (Click to add new item, select from combobox, press Enter), the values in the grid disappear until the grid is clicked on.
3. Pasting a column of values from Excel does not work. Objects are added to the collection but the value is that of the last manually selected value from one of the ComboBoxes.
<
telerik:RadGridView
Grid.Row
=
"2"
HorizontalAlignment
=
"Stretch"
Name
=
"radGridView3"
VerticalAlignment
=
"Stretch"
CanUserFreezeColumns
=
"False"
AutoGenerateColumns
=
"False"
CanUserReorderColumns
=
"False"
CanUserResizeColumns
=
"False"
CanUserSortColumns
=
"False"
ShowColumnHeaders
=
"True"
ShowGroupPanel
=
"False"
ShowInsertRow
=
"True"
RowIndicatorVisibility
=
"Visible"
SelectionUnit
=
"Cell"
ItemsSource
=
"{Binding AllLocations, Mode=TwoWay}"
>
<
telerik:RadGridView.Columns
>
<
local:RowNumberColumn
Header
=
""
Width
=
"50"
/>
<
telerik:GridViewComboBoxColumn
DataMemberBinding
=
"{Binding CountryId, Mode=TwoWay}"
SelectedValueMemberPath
=
"Id"
DisplayMemberPath
=
"Name"
ItemsSource
=
"{Binding AllCountries}"
/>
</
telerik:RadGridView.Columns
>
</
telerik:RadGridView
>
How do I fix this and have pasting working with Xaml databinding?