Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > TabControl > AllowDragReorder and IsContentPreserved

Not answered AllowDragReorder and IsContentPreserved

Feed from this thread
  • Brock avatar

    Posted on Aug 29, 2011 (permalink)

    Hi,

    We are currently using the tabcontrol with IsContentPreserved="true".  This works beautifully at preserving the viewmodels, that is until we drag the tabs to re-order them.  When the tabs are reordered the tab being dragged loses it content and the viewmodel is recreated.  As a result a user loses all their data etc.

    Background
    • We are utilising the CINCH V2 MVVM framework which makes use of MEF as a viewmodel locator
    • Our viewmodels are all set to non-shared (in MEF) and are set to the views datacontext via

      meffed

       :ViewModelLocator.ViewModel="{x:Static ViewModels:ViewModelKeys.MainWindowViewModel}"

    • Our tabcontrol has it's item source bound as ItemsSource="{Binding Views}"
    • We dynamically add tabs programmatically via

    var workspace = new ValidatingAwareWorkspace(null, viewToDisplayInTab, workspaceDataParameter, tabLabel, true);

     Views.Add(workspace); 

    • This also uses MEF to determine which view to display via the key "viewToDisplayInTab" and displays that view on the tab via the following datatemplate

    <DataTemplate DataType="{x:Type CinchV2:WorkspaceData}">

        <AdornerDecorator>

            <Border HorizontalAlignment="Stretch"

                    VerticalAlignment="Stretch"

                    Margin="2"

                    CinchV2:NavProps.ViewCreator="{Binding}"/>

        </AdornerDecorator>

    </DataTemplate>

     

    What i'm after:
    I understand that there are obviously a lot of factors at play here that could be breaking the IsContentPreserved when reordering tabs but i thought i would post here to see if you guys have any ideas because it only breaks when i set AllowDragReorder to true

    Thanks,
    Brock

     

    Reply

  • Tina Stancheva Tina Stancheva admin's avatar

    Posted on Sep 1, 2011 (permalink)

    Hello Brock,

    Indeed when the tabs are reordered the content is not preserved. Basically during the DragReorder operation the TabItems are removed from the RadTabControl.Items(ItemsSource) collection and inserted again at the new position.

    This is why when you start to drag a tab, the RadTabControl invalidates its DataTemplates and bindings. And when you drop it on the new position, the bindings and the templates are recreated.

    However, I logged a feature request to keep the content of the dragged items during the reordering operation and if the item gathers enough popularity, we will definitely consider implementing it. I also updated your Telerik account for your feedback on the matter.

    Kind regards,
    Tina Stancheva
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

    Reply

  • Brock avatar

    Posted on Sep 1, 2011 (permalink)

    Thanks Tina,

    Being able to drag the tabs is a great feature that would have been awesome to use but obviously content preservation takes precedence in this case.

    Is it possible to change the order programmtically while maintaing the content? if that is the case i could bind up the left and right arrows keys or someting have buttons etc to achieve the re ordering?

    Reply

  • Hristo Hristo admin's avatar

    Posted on Sep 2, 2011 (permalink)

    Hello Brock,

    The reason for this behaviour is that items are removed and added to the items collection during the reordering. So, if you are able to reorder the items collection without removing items from it, you will be able to preserve the content.

    Please let us know if you have further considerations.

    Greetings,
    Hristo
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > TabControl > AllowDragReorder and IsContentPreserved
Related resources for "AllowDragReorder and IsContentPreserved"

WPF TabControl Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]