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

Close event doesn't fire

3 Answers 78 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Lilia
Top achievements
Rank 1
Lilia asked on 12 Jul 2011, 03:48 PM
Hello Telerik team,

I'm binding the RadDocking ItemsSource to a ObservableCollection<RadDocumentPane> (TabItems in the example) collection.

<telerik:RadDocking.DocumentHost>
     <telerik:RadPaneGroup Name="paneGroupTabs"
            ItemsSource="{Binding Path=TabItems}">                   
     </telerik:RadPaneGroup>
</telerik:RadDocking.DocumentHost>

When I try to close a pane an exception is thrown:
Code: 4004 ....Operation not supported on read-only collection.

So I try to handle the Close event (or any other event) so I can remove the Pane from the source and rebind again to the Docking control, but that exception is thrown before any event I can catch. What should I do?


3 Answers, 1 is accepted

Sort by
0
Accepted
Miroslav Nedyalkov
Telerik team
answered on 13 Jul 2011, 09:16 AM
Hi Lilia,

 The Docking control (and PaneGroup and SplitContainer controls) doesn't support ItemsSource as they use their Items collections. For more information about this matter you may refer to this help article. In this forum thread is discussed how you could overcome this limitation.

As for your approach - you could also use the Docking events in order to overcome this limitation as you correctly noticed, but you need to use the PreviewClose event and to handle it. This will stop the actual removing from the Items collection and the exception will not be thrown.

Hope this information is helpful.

Best wishes,
Miroslav Nedyalkov
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Lilia
Top achievements
Rank 1
answered on 13 Jul 2011, 10:04 AM
Hello Miroslav,

Thank you for your reply. I tried to do the trick like it's described in the article you send me and it's working fine with little modifications.
Although, I want to try to do it my way with the PreviewClose event. It's firing, I'm removing the appropriate Pane from the TabItems
 source. But at the end another error is thrown. Here is the InnerException:

InnerException  {System.NullReferenceException: Object reference not set to an instance of an object.
   at Telerik.Windows.Controls.RadDocking.OnPaneClose(RadPane pane)
   at Telerik.Windows.Controls.RadDocking.OnRadPaneClose(Object sender, StateChangeCommandEventArgs args)}  System.Exception {System.NullReferenceException}

Do you have any idea why is that?




0
Miroslav Nedyalkov
Telerik team
answered on 13 Jul 2011, 02:15 PM
Hello Lilia,

 What I would suggest you is to not remove the pane immidiately when the event is fired as the Docking control doesn't expect the pane to be removed when this event is fired as it should take care for this. Solution for this could be to run the operation using the Dispatcher.BeginIvoke method.

Hope this helps.

Regards,
Miroslav Nedyalkov
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
Docking
Asked by
Lilia
Top achievements
Rank 1
Answers by
Miroslav Nedyalkov
Telerik team
Lilia
Top achievements
Rank 1
Share this question
or