This is a migrated thread and some comments may be shown as answers.

AllowDragReorder and IsContentPreserved

5 Answers 144 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
Brock
Top achievements
Rank 1
Brock asked on 30 Aug 2011, 02:13 AM
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

 

5 Answers, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 01 Sep 2011, 05:13 PM
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 >>

0
Brock
Top achievements
Rank 1
answered on 02 Sep 2011, 01:59 AM
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?
0
Hristo
Telerik team
answered on 02 Sep 2011, 04:37 PM
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 >>

0
Eugene
Top achievements
Rank 1
answered on 24 Jun 2015, 02:55 PM

Hello Telerik.

Could you provide the curent state of a feature request to keep the content of the dragged items during the reordering operation.
Unfortunately an'm unable to check it via link, provided by Tina Stancheva.

Currently I have the same issue when dragging tab items within TabControl with IsContentPreserved="true" and i'm highly interested in keeping the existing content.

Thanks!

0
Martin Ivanov
Telerik team
answered on 29 Jun 2015, 01:57 PM
Hi Eugene,

This feature is dropped and we do not have plans for implementing it in near future. This is due the specific implementation of the tab control's drag/drop logic, which includes adding/removing items in the visual tree during the drag operation.

Regards,
Martin
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
TabControl
Asked by
Brock
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Brock
Top achievements
Rank 1
Hristo
Telerik team
Eugene
Top achievements
Rank 1
Martin Ivanov
Telerik team
Share this question
or