RaisePropertyChanged does not work in catch if there is a throw

2 posts, 0 answers
  1. Jaypee
    Jaypee avatar
    13 posts
    Member since:
    Jun 2013

    Posted 09 Oct 2014 Link to this post

    the Code below is Bound to IsExpanded of RadTreeItem


    public
    bool IsExpanded
           {
               get
               {
                   return isExpanded;
               }
               set
               {
                   try
                   {
                       if (isExpanded != value)
                       {
                           if (value)
                           {
                               if (Children.Contains(dummy))
                               {
                                   Children.Remove(dummy);
                               }
                               LoadChildren();
                           }
                       }
                       isExpanded = value;
                       RaisePropertyChanged(() => IsExpanded);
                   }
                   catch (Exception e)
                   {
                       if (!HasItems)
                       {
                           //if empty, add dummy to keep the expander.
                           Children.Add(dummy);
                       }
                       //any exception will keep this node collapsed.
                       isExpanded = false;
                       RaisePropertyChanged(() => IsExpanded);
                       throw;
                   }
               }
           }


    Inside the catch statement, I want to force collapse the treeitem if there is an error. If I put "throw" the tree item DOES NOT collapse. when I remove the "throw" it collapses successfully. Why "throw" is preventing the treeitem to collapse? 


    We need the "throw" because IsExpanded is called by another method that catches the exception and do some logic.

     
  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 13 Oct 2014 Link to this post

    Hi Jaypee,

    I strongly believe that this is related to the way WPF Framework works. Throwing the exception might somehow prevent the UI from updating successfully. What you can do is to test this scenario with some MS WPF Control. If the problem persist, probably this is something in the framework. If not, you can send us a runnable sample in a new support thread that we will investigate locally. Thank you in advance for your cooperation.

    Regards,
    Petar Mladenov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top