Close event doesn't fire

4 posts, 1 answers
  1. Lilia
    Lilia avatar
    32 posts
    Member since:
    Mar 2011

    Posted 12 Jul 2011 Link to this post

    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?


  2. Answer
    Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 13 Jul 2011 Link to this post

    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!

  3. DevCraft banner
  4. Lilia
    Lilia avatar
    32 posts
    Member since:
    Mar 2011

    Posted 13 Jul 2011 Link to this post

    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?




  5. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 13 Jul 2011 Link to this post

    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!

Back to Top