or
I have a RadGridView bound to ObservableCollection. This collection is constantly updated and on first binding the grid represent the data correctly. But then I click on one of the headers to sort the data in the grid. After that behaviors on adding a new row become as following:
- the grid adds the row to the end of the list only, it doesn't sort data dynamically according sorting column;
- sometimes (often) the grid creates duplicate rows while underlying collection contains correct data;
I couldn't find in documentation any info that I should programmatically sort underlying collection each time after adding row or rebind it every time so the grid shows it correctly. What should I do to fix it or it\s a norm for Telerik Grid?
<telerik:RadTreeView ItemPrepared="OnItemPrepared" .../> protected void OnItemPrepared(object sender, RadTreeViewItemPreparedEventArgs e) { if (e.PreparedItem.AllowDrop) { e.PreparedItem.DragEnter += OnPreparedItemDragEnter; e.PreparedItem.Drop += OnPreparedItemDrop; } }if(dialog.ShowDialog == true){ DoSomething();}DoCleanup();var manager = new PersistenceManager();var stream = manager.Save(dgOrderOverview);using (var fileStream = File.Create(System.AppDomain.CurrentDomain.BaseDirectory + "\\objstore.hf")){ stream.CopyTo(fileStream);}//Check if any persistence file exists, and if so, load the viewif (File.Exists(System.AppDomain.CurrentDomain.BaseDirectory + "\\objstore.hf")){ var manager = new PersistenceManager(); try { var fileStream = File.OpenRead(System.AppDomain.CurrentDomain.BaseDirectory + "\\objstore.hf"); manager.Load(dgOrderOverview, fileStream); fileStream.Close(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message, "MYAPPNAME"); }}//Load Context MenuRadContextMenu ctxMenu = new RadContextMenu();RadMenuItem item = new RadMenuItem();foreach (Telerik.Windows.Controls.GridViewColumn column in dgOrderOverview.Columns){ RadMenuItem sitem = new RadMenuItem() { Header = column.Header, IsCheckable = true, IsChecked = true }; sitem.SetBinding(RadMenuItem.IsCheckedProperty, new Binding("IsVisible") { Mode = BindingMode.TwoWay, Source = column }); ctxMenu.Items.Add(sitem);}RadContextMenu.SetContextMenu(dgOrderOverview, ctxMenu);<telerik:RadDataForm x:Name="dataForm" ItemsSource="{Binding Items}"/><telerik:RadListBox x:Name="ListBox" ItemsSource="{Binding Items}" SelectedIndex="0" /> private ICollectionView _items; public ICollectionView Items { get { if (_items== null) { Items = new QueryableCollectionView(new ObservableCollection<Contact>(RepositoryBase.Context.Contacts)); } return _items; } set { if (Equals(value, _items)) return; _items= value; NotifyOfPropertyChange(() => Items); } }