Arrow doesn't appear

4 posts, 0 answers
  1. Benoit
    Benoit avatar
    2 posts
    Member since:
    Jun 2017

    Posted 09 Jun Link to this post

    Hi, 

    I'm working with a RadTreeview binded to an ObservableCollection.

    All is fine, until I add a new item in my collection, a new row is created, but the left arrow (to expand) doesn't appear. 

    I have to expand with a double click to let it appear. After that all is fine.

    Can someone help me ? 

     

    Thanks, 

    Benoit.

    01.<telerik:RadTreeView ItemsSource="{Binding Directories}" SelectedItem="{Binding SelectedItem, Mode=TwoWay}" Grid.Row="1" Background="White">
    02.            <telerik:RadTreeView.ItemContainerStyle>
    03.                <Style TargetType="telerik:RadTreeViewItem">
    04.                    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
    05.                </Style>
    06.            </telerik:RadTreeView.ItemContainerStyle>
    07.            <telerik:RadTreeView.ItemTemplate>
    08.                <HierarchicalDataTemplate ItemsSource="{Binding FilesList}">
    09.                    <Grid HorizontalAlignment="Stretch">
    10.                        <Grid.ColumnDefinitions>
    11.                            <ColumnDefinition Width="*"></ColumnDefinition>
    12.                            <ColumnDefinition Width="Auto"></ColumnDefinition>
    13.                        </Grid.ColumnDefinitions>
    14.                        <TextBlock Grid.Column="0" Text="{Binding Name}" VerticalAlignment="Center"/>
    15.                        <Button Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center" Content="Export">
    16.                    </Grid>
    17.                </HierarchicalDataTemplate>
    18.            </telerik:RadTreeView.ItemTemplate>
    19.        </telerik:RadTreeView>
  2. Martin Ivanov
    Admin
    Martin Ivanov avatar
    1408 posts

    Posted 14 Jun Link to this post

    Hello Benoit,

    I tested your code but I wasn't able to reproduce the reported behavior. Can you give the attached project a try and let me know if I am missing something?

    Additionally, the arrow won't be displayed if the children collection of the added node is empty.

    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.
  3. Benoit
    Benoit avatar
    2 posts
    Member since:
    Jun 2017

    Posted 26 Jun in reply to Martin Ivanov Link to this post

    Hi Martin, 

     

    Thanks for your reply. 

    I triedwith your project, and it works perfectly... I really don't understand.

    I fill my RadTreeView with a FileSystemWatcher, but i don't think my problem comes from this.ee my code which fill my ObservableCollection.

     

    Thanks,

    Benoit.

    01._watcher.Do_OnAdd =
    02.                (it) =>
    03.                {
    04.                    if (it.GetType() != typeof(FileInfo))
    05.                        return;
    06. 
    07.                    DirectoryInfo greatGrandParent = ((FileInfo)it).Directory.Parent.Parent.Parent;
    08. 
    09.                    if (!StitchingDirectories.Any((dir) => dir.FullName == greatGrandParent.FullName))
    10.                    {
    11.                        _dispatcher.Invoke(new Action(() => StitchingDirectories.Add(new StitchingDirectory(greatGrandParent.FullName, _dispatcher))));
    12.                    }
    13. 
    14.                    StitchingDirectories.Where((dir) => dir.FullName == greatGrandParent.FullName).FirstOrDefault().AddDzi(it as FileInfo);
    15.                };
     
    1. public void AddDzi(FileInfo dziFile)
    2. {
    3.     _dispatcher.BeginInvoke(new Action(() => FilesList.Add(dziFile)));
    4. }
  4. Martin Ivanov
    Admin
    Martin Ivanov avatar
    1408 posts

    Posted 28 Jun Link to this post

    Hello Benoit,

    Without a runnable project showing the issue I cannot be sure what happens, but here are two guesses which you can take into account and check in your project.
    • If the collection property bound to the ItemsSource of the treeview or the hierarchical template is set a bit later - after the control is loaded - and the collection property doesn't fires the PropertyChanged event, this could happen. Probably, the items are displayed on double click because this triggers some measurements in the item. Make sure that the bound collection implements the INotifyCollectionChanged interface and also the property that holds it fires PropertyChanged event.
    • If the treeview item where the arrow is missing doesn't have children originally and they are added on a specific action, as double click for example, the arrow  won't display, but this is expected behavior.

    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.
Back to Top