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

IsExpanded overrides binding on initialization

10 Answers 184 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Brian
Top achievements
Rank 1
Brian asked on 12 Dec 2013, 05:56 PM
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#

10 Answers, 1 is accepted

Sort by
0
Pavel R. Pavlov
Telerik team
answered on 17 Dec 2013, 11:45 AM
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 >>
0
Shilo
Top achievements
Rank 1
answered on 26 Nov 2017, 09:35 AM

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

  

0
Shilo
Top achievements
Rank 1
answered on 26 Nov 2017, 09:42 AM
Hi Pavel,
The last comment I wrote was for you (not for Brian)
Shilo
0
Martin Ivanov
Telerik team
answered on 29 Nov 2017, 02:49 PM
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.
0
Arthur
Top achievements
Rank 1
answered on 31 Jan 2020, 10:52 AM

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

0
Arthur
Top achievements
Rank 1
answered on 31 Jan 2020, 11:38 AM
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.
0
Martin Ivanov
Telerik team
answered on 04 Feb 2020, 10:48 AM

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.
0
Arthur
Top achievements
Rank 1
answered on 04 Feb 2020, 11:01 AM

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

0
Arthur
Top achievements
Rank 1
answered on 04 Feb 2020, 12:38 PM

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

0
Martin Ivanov
Telerik team
answered on 04 Feb 2020, 01:28 PM

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.
Tags
TreeView
Asked by
Brian
Top achievements
Rank 1
Answers by
Pavel R. Pavlov
Telerik team
Shilo
Top achievements
Rank 1
Martin Ivanov
Telerik team
Arthur
Top achievements
Rank 1
Share this question
or