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

MVVM: remove the viewModel when pane is closed

1 Answer 126 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Yehudah
Top achievements
Rank 1
Yehudah asked on 12 May 2014, 06:42 AM
hello!

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?

thanks!

1 Answer, 1 is accepted

Sort by
0
Vladi
Telerik team
answered on 13 May 2014, 02:49 PM
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.

Regards,
Vladi
Telerik
 
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.
 
Tags
Docking
Asked by
Yehudah
Top achievements
Rank 1
Answers by
Vladi
Telerik team
Share this question
or