wpf - What is the proper way to handle multiple datagrids in a tab control so that cells leave edit mode when the tabs are changed? -


wpf I have a tab control setup does have a data template with the data grid for each object that bind the collection of objects Happens information If I select a particular cell and puts it in edit mode, my grid will be placed on the return Detagrid go exception, except on the second tab:

'Deferr Rifesh' AddNew or EditItem transactions.

It seems that cell has never left the editing mode, is an easy way to get the cell out of editing mode, or is there anything else on here?

Update: It seems that I have a tab control to the data source, but instead clearly defined in each tab and then bind the data source to the content source to each source Let this problem go away. This is not really a great solution, so I still want to know how to tie the collection directly into the tab control.

Update: So what I have really done for myself is to use a list view and content control in place of a tab control instead of being able to solve oneself. I use a style to make a list of tabs to see. The visual model displays a set of child's visual model and lets the user select one through the list view. Content control then presents the selected visual model and each visual model has a related data template that has a data grid. When switching between this setup view model, the editing mode on the grid ends in the editing mode and the data is saved.

It is xaml to set:

  & lt; ListView ItemTemplate = "{StaticResource MakeItemsLookLikeTabs}" Aitmsors = "{Binding ViewModels}" SelectedItem = "{Binding select}" style = "{StaticResource MakeItLookLikeATabControl}" / & gt; & Lt; Content control content = "{bound select}" & gt;  

I accept Phil's answer as I should also work, but for me it seems to me that it will be more portable between projects.

I have this problem is to detect and manage the user a TabItem on Clicks and then makes visible> edits on the code> DataGrid in TabControl . I'm assuming that the user will expect his changes to be that he will still be there when he clicks back.

The code snippet:

  // PreviewMouseDown event handler TabControl private TabControl_PreviewMouseDown zero (object sender, Maubuttn avent Argij e) {if (Aisyuentrtabhader (e. Original source of Dependency object)) Cometables (your tab control); } Private Bull ISUender tabbahder (dependent object control) {if (control tab is the item) returns true; DependentObject Origin = VisualTriperGetPerint (Control); If (parent == zero) return false; Return IsUnderTabHeader (parent); } Private Zero CommitTables (Dependency Object Control) {if (control is DataGrid) {DataGrid Grid = DataGrid controls as; Grid CometEdit (DataGrid editing unit. Row, true); Return; } Int Children Count = VisualTriehlper Gate child (control); (Int bit index = 0; child index & lt; childrenCount; childIndex ++) committable (visitorHelperGetChild (control, child index)); }  

It is behind the code.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -