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

RaisePropertyChanged does not work in catch if there is a throw

1 Answer 74 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Jaypee
Top achievements
Rank 1
Jaypee asked on 10 Oct 2014, 01:42 AM
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.

 

1 Answer, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 13 Oct 2014, 07:08 AM
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.

 
Tags
TreeView
Asked by
Jaypee
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Share this question
or