Good Day,
I think I found a bug in the DataGrid.
When you remove an item from the Datagrids itemsource bound ObservableCollection, the datagrid deletes the wrong item. So I started to debugged it => after the delete the itemsource is right but the view you see is wrong. (maybe a caching bug?)
You can easily reproduce this bug if you take your FirstLook example project.
Remove the label on top and add an button instead. Make a property for selectedItem in the mainViewmodel and bind it to the datagrids selected item.
On button click you do:
ViewModel.OrderDetails.Remove(ViewModel.Selected);
Here is the code:
namespace Examples.DataGrid.FirstLook{ public partial class Example : ContentPage { public MainViewModel ViewModel { get; set; } public Example() { InitializeComponent(); ViewModel = new MainViewModel(); this.BindingContext = ViewModel; } protected override void OnAppearing() { base.OnAppearing(); var rootGrid = this.Content as Grid; if (Examples.Helpers.ExampleHelper.SetImageButtonOnTop(ref rootGrid)) { this.Content = rootGrid; } } private void Button_OnClicked(object sender, EventArgs e) { ViewModel.OrderDetails.Remove(ViewModel.Selected); } }}<?xml version="1.0" encoding="utf-8" ?><ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:telerikDataGrid="clr-namespace:Telerik.XamarinForms.DataGrid;assembly=Telerik.XamarinForms.DataGrid" xmlns:common="clr-namespace:Telerik.XamarinForms.Common.Data;assembly=Telerik.XamarinForms.Common" xmlns:examples="clr-namespace:Examples;assembly=Examples" x:Class="Examples.DataGrid.FirstLook.Example"> <Grid> <Grid.BackgroundColor> <OnPlatform x:TypeArguments="Color"> <OnPlatform.Android>White</OnPlatform.Android> </OnPlatform> </Grid.BackgroundColor> <Grid.Behaviors> <examples:CustomBehavior /> </Grid.Behaviors> <Grid.Resources> <ResourceDictionary> <examples:UwpImageSourceConverter x:Key="UwpImageSourceConverter"/> </ResourceDictionary> </Grid.Resources> <Grid> <Grid.RowDefinitions> <RowDefinition Height="58"/> <RowDefinition/> </Grid.RowDefinitions> <Button Text="Delete selected Pos" Clicked="Button_OnClicked"></Button> <telerikDataGrid:RadDataGrid Grid.Row="1" ItemsSource="{Binding OrderDetails}" AutoGenerateColumns="False" SelectionUnit="Row" SelectionMode="Single" UserEditMode="Cell" SelectedItem="{Binding Selected, Mode=TwoWay}"> <telerikDataGrid:RadDataGrid.Columns> <telerikDataGrid:DataGridTemplateColumn HeaderText="Ship owner"> <telerikDataGrid:DataGridTemplateColumn.CellContentTemplate> <DataTemplate> <Image Source="{Binding EmployeeImage, Converter={StaticResource UwpImageSourceConverter}}" Aspect="AspectFit" Margin="0, 2, 0, 2" WidthRequest="50" HeightRequest="50"/> </DataTemplate> </telerikDataGrid:DataGridTemplateColumn.CellContentTemplate> </telerikDataGrid:DataGridTemplateColumn> <telerikDataGrid:DataGridNumericalColumn PropertyName="OrderID" HeaderText="Order ID"/> <telerikDataGrid:DataGridTextColumn PropertyName="ShipName" HeaderText="Ship name"/> </telerikDataGrid:RadDataGrid.Columns> </telerikDataGrid:RadDataGrid> </Grid> </Grid></ContentPage>
namespace Examples.DataGrid.FirstLook{ public class MainViewModel { public MainViewModel() { this.OrderDetails = DataGenerator.GenerateOrderDatails(); } public ObservableCollection<Order> OrderDetails { get; set; } public Order Selected { get; set; } }}