c# - Why do my TextBoxes in different tabs of a TabControl lose their undo history? -


i have tabcontrol textbox controls in contenttemplate. when type text in 1 tab , switch tab, undo history in original tab gone when go back.

another problem comes text selected deselected , caret moves beginning of textbox.

if make window hardcoded tabitem controls, undo history preserved. issue has binding or templates.

here xaml main window

<window x:class="tabbedtextareatest.mainwindow"         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"         title="mainwindow" height="350" width="525">     <grid>         <grid.rowdefinitions>             <rowdefinition height="auto"/>             <rowdefinition/>         </grid.rowdefinitions>         <button command="{binding addnewtab}">add tab</button>         <tabcontrol itemssource="{binding tabs}" grid.row="1">             <tabcontrol.itemtemplate>                 <datatemplate>                     <textblock text="{binding header}"/>                 </datatemplate>             </tabcontrol.itemtemplate>             <tabcontrol.contenttemplate>                 <datatemplate>                     <textbox text="{binding content, mode=twoway, updatesourcetrigger=propertychanged}"/>                 </datatemplate>             </tabcontrol.contenttemplate>         </tabcontrol>     </grid> </window> 

is there way preserve undo/redo history , selected text when switching tabs without manually catching commands?

when use tabcontrol gets tabs via databinding on itemssource, wpf doesn't keep visual tree each item around switch. thus, when switch tab 1 tab 2, tab 1, controls on tab 1 not same control instances saw on tab 1 first time.

there number of ways around deal - tabcontrols have explicit tabitem instances keep visual trees when switch tabs, easiest way wrap collection of tab items in makes tabitems them.

unfortunately right can't find link example of how this. there references articles elsewhere on so, seem point pages no longer exist, , don't have time dig deeper.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -