AllowDragReorder and IsContentPreserved

6 posts, 0 answers
  1. Brock
    Brock avatar
    5 posts
    Member since:
    Jun 2011

    Posted 29 Aug 2011 Link to this post

    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

     

  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 01 Sep 2011 Link to this post

    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 >>

  3. UI for WPF is Visual Studio 2017 Ready
  4. Brock
    Brock avatar
    5 posts
    Member since:
    Jun 2011

    Posted 01 Sep 2011 Link to this post

    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?
  5. Hristo
    Admin
    Hristo avatar
    352 posts

    Posted 02 Sep 2011 Link to this post

    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 >>

  6. Eugene
    Eugene avatar
    4 posts
    Member since:
    Nov 2014

    Posted 24 Jun 2015 Link to this post

    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!

  7. Martin
    Admin
    Martin avatar
    1101 posts

    Posted 29 Jun 2015 Link to this post

    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
Back to Top
UI for WPF is Visual Studio 2017 Ready