We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

SelectedTreeItem

Hi all togehter,

i use the TreeViewAdv Control in my WPF Application.

<ScrollViewer Grid.Row="1">
            
            <syncfusion:TreeViewAdv x:Name="Tree"
                

                ItemsSource="{Binding ProjectsView}"
                SelectedTreeItem="{Binding SelectedProject,Mode=TwoWay}"
                AllowMultiSelect="False"
        
                SelectionChanged="Tree_SelectionChanged"
            >
                
                <syncfusion:TreeViewAdv.ItemTemplate>
                    <HierarchicalDataTemplate ItemsSource="{Binding SubProjects}" >
                        <ContentControl Content="{Binding}"
                                        ContentTemplate="{StaticResource ProjectsSelectionTemplate}" />
                    </HierarchicalDataTemplate>
                </syncfusion:TreeViewAdv.ItemTemplate


                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="MouseDoubleClick">
                        <i:InvokeCommandAction
                            Command="{Binding EntitySelectedCommand,diag:PresentationTraceSources.TraceLevel=High}" >
                        </i:InvokeCommandAction>
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </syncfusion:TreeViewAdv>
        </ScrollViewer>

Part of ViewModel wher PrpjectsView i typeop ICollectionView

ProjectDto _selectedProject;
        public ProjectDto SelectedProject {
            get {return _selectedProject;}
            set {
                
                SetProperty(ref _selectedProject,value);
                System.Threading.Thread.Sleep(500);
                if (SelectedProject != null) {
                    Console.WriteLine("Selected {0}",SelectedProject.ProjectName);
                    ProjectsView.MoveCurrentTo(SelectedProject);
                }
            }
        }

When i scroll down the Tree an click an Item, the SelectedTreeItem changes, but, the Tree always jump to the first position.

This works only with he line 'Thread.Sleep(500). If i comment out this line, the tree scrolls only to the first position, so there is no selection.

Any ideas?

Thanks

Peter


4 Replies

FP Forstmeier Peter June 1, 2017 04:28 AM UTC

Hi,

me again.

is nobody outside who can help me.

This is a very serious problem i i never see this behavior bevore.


Thanks

Peter



VR Venkateshwaran Ramdoss Syncfusion Team June 1, 2017 09:18 AM UTC

Hi Peter,   
  
Thank you for contacting Syncfusion Support.   
  
We have validated this reported behavior and it has a problem with AutoScrolling functionality in ScrollViewer control. It has been discussed in below MSDN article.    
   
   
As explained in above MSDN article, this reported behavior can be resolved handling RequestBringIntoView event. Kindly make use of the below code example for your reference.   
   
Code example   
   
XAML   
   
<syncfusion:TreeViewAdv  x:Name="TreeView"RequestBringIntoView="TreeView_RequestBringIntoView"    
ItemsSource="{Binding Customers}" SelectedTreeItem="{BindingSelectedTreeItem,Mode=TwoWay}">   
   
   
C#   
   
private void TreeView_RequestBringIntoView(object sender, RequestBringIntoViewEventArgse)   
        {   
            e.Handled = true;   
        }   
   
   
We have also prepared sample and video for your reference and it can be downloaded from the below link.   
   
  
  
Please check the above solution and let us know if it is helpful.   
  
Regards,   
Venkateshwaran V.R.   
 



FP Forstmeier Peter June 2, 2017 07:15 AM UTC

Works perfectly

Thanks a lot

Peter



VR Vijayalakshmi Roopkumar Syncfusion Team June 5, 2017 04:02 AM UTC

Hi Peter

Thank you for your update.

Please let us know if you need any further assistance on this.

Regards,
Vijayalakshmi V.R.


Loader.
Up arrow icon