IsExpanded overrides binding on initialization

11 posts, 0 answers
  1. Brian
    Brian avatar
    1 posts
    Member since:
    Dec 2013

    Posted 12 Dec 2013 Link to this post

    I have databound RadTreeViewItem.IsExpanded in my item container style, but when the item is created, it ignores the binding (which is set to true) and sets the property to false.  I found another thread in the forum describing the same behavior happening with the IsChecked property.

    Call stack:

      Telerik.Windows.Controls.Navigation.dll!Telerik.Windows.Controls.RadTreeViewItem.IsExpanded.set(bool value) Line 390 C#
    > Telerik.Windows.Controls.Navigation.dll!Telerik.Windows.Controls.RadTreeViewItem.OnIsExpandedChanged(bool oldValue, bool newValue) Line 1186 C#
      Telerik.Windows.Controls.Navigation.dll!Telerik.Windows.Controls.RadTreeView.RestoreContainerProperties(object item, Telerik.Windows.Controls.RadTreeViewItem treeViewItem) Line 678 C#

  2. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1251 posts

    Posted 17 Dec 2013 Link to this post

    Hello Brian,

    I tried to reproduce the reported behavior on our side with our latest official release and it seems that the code works as expected. Could you please take a look at the attached project and let us know if there is something that I missed? It will be great if you can change the code so that the issue can be reproduced on our side and send it over. By doing this we will be able to further investigate the possible reasons behind.

    Regards,
    Pavel R. Pavlov
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. Shilo
    Shilo avatar
    2 posts
    Member since:
    Jul 2012

    Posted 26 Nov 2017 in reply to Pavel R. Pavlov Link to this post

    Hi Brian,

    I have the same problem.

    The Binding continues until I manually expand or collapse the node.
    At that moment, the Binding is stopped.

    The problem also exists in the example you sent.

    I demonstrated the problem in the video. See attached link.

    https://www.dropbox.com/s/4gyh9f63399gbem/ScreenCapture_26-11-2017%2011.21.50.wmv?dl=0

    Shilo

      

  4. Shilo
    Shilo avatar
    2 posts
    Member since:
    Jul 2012

    Posted 26 Nov 2017 in reply to Pavel R. Pavlov Link to this post

    Hi Pavel,
    The last comment I wrote was for you (not for Brian)
    Shilo
  5. Martin Ivanov
    Admin
    Martin Ivanov avatar
    2391 posts

    Posted 29 Nov 2017 Link to this post

    Hello Brian,

    To update the property of the model (DataItem) when you expand/collapse a node manually you can set the Mode of the binding to TwoWay.
    <Style TargetType="telerik:RadTreeViewItem" x:Key="MyStyle">
        <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
    </Style>

    Regards,
    Martin Ivanov
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
  6. Arthur
    Arthur avatar
    16 posts
    Member since:
    Oct 2015

    Posted 31 Jan Link to this post

    I have the same problem. I have the IsExpanded Binding bound two way, the bound property value in the node view model is initialized to true, before the item becomes visible. Then this value is set to false with the following call stack. Please advice how to stop that. Otherwise I cannot define a preexpanded tree.

    >    Ade.Hierarchies.dll!Ade.Hierarchies.DefaultHierarchyTreeVisualStateProvider.SetIsExpanded(System.Guid nodeId, bool isExpanded) Line 52    C#
         Ade.Hierarchies.UIImpl.dll!Ade.Hierarchies.UI.HierarchyTreeNodeViewModel.IsExpanded.set(bool value) Line 283    C#
         [Native to Managed Transition]    
         [Managed to Native Transition]    
         PresentationFramework.dll!MS.Internal.Data.PropertyPathWorker.SetValue(object item, object value)    Unknown
         PresentationFramework.dll!System.Windows.Data.BindingExpression.UpdateSource(object value)    Unknown
         PresentationFramework.dll!System.Windows.Data.BindingExpressionBase.UpdateValue()    Unknown
         PresentationFramework.dll!System.Windows.Data.BindingExpressionBase.ProcessDirty()    Unknown
         PresentationFramework.dll!System.Windows.Data.BindingExpressionBase.Dirty()    Unknown
         PresentationFramework.dll!System.Windows.Data.BindingExpressionBase.SetValue(System.Windows.DependencyObject d, System.Windows.DependencyProperty dp, object value)    Unknown
         WindowsBase.dll!System.Windows.DependencyObject.SetValueCommon(System.Windows.DependencyProperty dp, object value, System.Windows.PropertyMetadata metadata, bool coerceWithDeferredReference, bool coerceWithCurrentValue, System.Windows.OperationType operationType, bool isInternal)    Unknown
         WindowsBase.dll!System.Windows.DependencyObject.SetValue(System.Windows.DependencyProperty dp, object value)    Unknown
         Telerik.Windows.Controls.Navigation.dll!Telerik.Windows.Controls.RadTreeViewItem.OnIsExpandedChanged(bool oldValue, bool newValue)    Unknown
         Telerik.Windows.Controls.Navigation.dll!Telerik.Windows.Controls.RadTreeView.RestoreContainerProperties(object item, Telerik.Windows.Controls.RadTreeViewItem treeViewItem)    Unknown
         Telerik.Windows.Controls.Navigation.dll!Telerik.Windows.Controls.RadTreeView.PrepareContainerForDescendant(System.Windows.DependencyObject element, object item, System.Windows.Controls.ItemsControl owner)    Unknown
         Telerik.Windows.Controls.Navigation.dll!Telerik.Windows.Controls.RadTreeView.PrepareContainerForItemOverride(System.Windows.DependencyObject element, object item)    Unknown
         PresentationFramework.dll!System.Windows.Controls.ItemsControl.MS.Internal.Controls.IGeneratorHost.PrepareItemContainer(System.Windows.DependencyObject container, object item)    Unknown
         Telerik.Windows.Controls.Navigation.dll!Telerik.Windows.Controls.TreeView.TreeViewPanel.InsertContainer(int childIndex, System.Windows.UIElement container, bool isRecycled)    Unknown
         Telerik.Windows.Controls.Navigation.dll!Telerik.Windows.Controls.TreeView.TreeViewPanel.AddContainerFromGenerator(int childIndex, System.Windows.UIElement child, bool newlyRealized)    Unknown
         Telerik.Windows.Controls.Navigation.dll!Telerik.Windows.Controls.TreeView.TreeViewPanel.MeasureOverride(System.Windows.Size constraint)    Unknown
         PresentationFramework.dll!System.Windows.FrameworkElement.MeasureCore(System.Windows.Size availableSize)    Unknown

  7. Arthur
    Arthur avatar
    16 posts
    Member since:
    Oct 2015

    Posted 31 Jan in reply to Arthur Link to this post

    The problem seems to occure with nodes that have no child nodes. It seems that the control resets the is expanded state to false in this case.
  8. Martin Ivanov
    Admin
    Martin Ivanov avatar
    2391 posts

    Posted 04 Feb Link to this post

    Hello Arthur,

    I've tested the reported behavior with the latest version of Telerik UI for WPF, but I wasn't able to reproduce the issue on my side. Can you check the attached project and let me know if I am missing anything?

    Regards,
    Martin Ivanov
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  9. Arthur
    Arthur avatar
    16 posts
    Member since:
    Oct 2015

    Posted 04 Feb in reply to Martin Ivanov Link to this post

    Hello Martin,

    I have opened a ticket and discussed the issue there. The problem occures, when the virtualization is turned on. Please see ticket 1451753 and the steps to reproduce. I hope that this issue reaches the developers as this is completely unexpected, that the virtualization changes the state of the view models.

    Regards,

    Arthur

  10. Arthur
    Arthur avatar
    16 posts
    Member since:
    Oct 2015

    Posted 04 Feb in reply to Arthur Link to this post

    For anybody having the same issue, you can vote for it here:

    https://feedback.telerik.com/wpf/1452191-treeview-add-an-option-to-prevent-setting-the-isexpanded-property-of-a-radtreeviewitem-that-has-no-children-to-false

  11. Martin Ivanov
    Admin
    Martin Ivanov avatar
    2391 posts

    Posted 04 Feb Link to this post

    Hello Arthur,

    Thank you for sharing the feedback item.

    Regards,
    Martin Ivanov
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top