Short version
public class CustomDataGrid : DataGridControl, IXmlSettingsProvider { public CustomDataGrid() { if (DesignModeHelper.IsInDesignMode) return; Loaded += (e, a) => { ... }; LostFocus += (e, a) => { if(IsBeingEdited ) EndEdit(); }; } }
How to find UIElement CurrentFocusTarget in the above example?
Long Version - Context
We use XCeed DataGrid to display data on different tabs of the lazily loaded TabControl. Each tab has a lazy load, so that the content gets visualized (and, more importantly, the data is retrieved) only when the tab is visible. The entire data stream works fine using the MVVM approach.
Problem
Be that as it may, whenever a user makes changes to the cell and the Changes tab , the ViewModel property with the database binding (which has already been updated) is set to null .
To avoid this, you can call EndEdit () when focus is lost from the grid.
However, I only want to call it when focus is lost for TabItem (or TabControl).
So my question is:
Which is the easiest way to find out where the Focus is right now , from the code. I checked FocusManager , but it seems that I could not find the current focus medium (or who lost focus).
source share