This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi There, I am using Mar 5. 2014 version nightly build. Here is a sceneary when it crashes: 1) In Window I have 2 tabs: a. one tab contains a data grid which is binding to a BindingList, the bindingList is changing overtimes, every time when new items comes in, I need to update in the data grid and put the last row in to view by calling dataGrid.BringRowIntoView(dataGrid.CurrentRecord); b. the 2nd tab has some other controls 2) When we set 2nd tab as the selected tab in the view, and datagrid in keep updating, it will crashes on System.NullReferenceException: Object reference not set to an instance of an object. at Mindscape.WpfElements.WpfDataGrid.DataGridItemsSource.#lcb(Object item) at Mindscape.WpfElements.WpfDataGrid.DataGridPanel.BringRowIntoView(Object rowContent) at CMG.CmostPlus.Studio.View.CmostPlusDataGrid.CurrentRecordsChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) in D:\cmostv\luxilongviewmain\cmost\Gen2\Projects\CMG.CmostPlus.Studio\View\Custom\CmostPlusDataGrid\CmostPlusDataGrid.cs:line 349.... The worst thing is that some times it is not throw an exception and make other part not working. I think the problem is because, that when we switch between tabs the control in previous tab get unloaded. But our application cannot stop updating when the datagrid's unloaded... Same code works for Version 5.0 though... Please try to catch the error in the DataGrid itself... Thanks, Gordon |
|
|
I also found that when the tab item is not in view(not current selection), the DataGrid.IsVisible will be false. I can add a condition check
Since this DataGrid.BringRowIntoView(Record) is not called, when we show the tab, I need to add a events like:
This solution really not very idealistic and also my other concern is that other updates on DataGrid, such as selection, or set selection items, etc, will be affected so it will be much better if you can fix it in your end... Thanks, Gordon |
|
|
Hello Jason, I have the same issue with "DataGrid.BringRowIntoView" . Btw, i have another issue with datagrid data not updated while received data from wcf services. please find in WpfDataGrid - Host -> WpfDataGrid -> View Models -> viewModel -> Public Sub SaveEditData(ByVal first As String, ByVal sur As String) i have write a remarks over there. Attached is a sample project , please run as administrator . Thanks, Yap |
|
|
Hello Gordon In the next nightly build, the null reference exception will be resolved. You are right that the DataGrid has been unloaded when the tab has been changed. Once the DataGrid is unloaded, all event handlers are unhooked, and some values are set to null in order to free all external memory references. This puts the DataGrid into an unusable state. The reason this worked in version 5 is because that was before I resolved the memory leaks related to properly disposing the DataGrid when it is unloaded. So the exception will be resolved, and you won't need to use the IsVisible trick, but it is recommended that where possible, you don't call functions on an unloaded DataGrid. Yap, The exception will be resolved for you too as this is roughly the same scenario. However, it will not functionally work without making some adjustments first. Currently you are calling BringRowIntoView while the DataGrid is still in an unloaded state. What you'll need to do is call the method after the DataGrid has loaded in order for this to functionally work. As for the data not updating, I don't know much about wcf services, but as long as the property change notification events are being raised on the row model objects, then the DataGrid will be updated. Maybe the Update method is somehow causing the events to not be raised. -Jason Fauchelle |
|