MVVM: remove the viewModel when pane is closed

2 posts, 0 answers
  1. Yehudah
    Yehudah avatar
    19 posts
    Member since:
    Feb 2014

    Posted 12 May 2014 Link to this post


    I try to use telerik-docking control with MVVM pattern.
    I saw this article, and others.

    my question is:

    I bind the PanesSource property to ObservableCollection<PaneViewModel>.

    when I add item to the ObservableCollection, it's add pane to the control,
    but, when I close any pane, it's not remove the viewmodel from the collection!

    How can I sync the collection with the panes well?

  2. Vladi
    Vladi avatar
    743 posts

    Posted 13 May 2014 Link to this post

    Hello Yehuda,

    Thank you for contacting us.

    By design in the current version of RadDocking when a RadPane's close button is pressed that instance is not actually fully closed but rather hidden by setting its IsHidden property to true. This is done in order to support reopening of such instances at later points. In order to fully remove a RadPane form the control you could call its RemoveFromParent method. In the scenario where you are using the PanesSource property of the control it is not necessary to call that method but simply remove the desired object from the bound collection to the PanesSource property. By doing so the RemovePane method of the controls DockingPanesFactory will be triggered and the RadPane will be both removed from the RadDocking and from the bound collection. You could use the RadDocking control's Close event in order to remove the object from the bound collection.

    I created and attached a sample project for you of the described approach, hope this is helpful.

    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
  3. DevCraft R3 2016 release webinar banner
Back to Top