ExpandItemByPath: Set Header

4 posts, 0 answers
  1. Matthias
    Matthias avatar
    26 posts
    Member since:
    Apr 2011

    Posted 16 Aug 2011 Link to this post


    Hi,

    I am having some problems with RadTreeView.ExpandItemByPath(...). It does not do anything when I call it.

    I guess the problem is that  I did not set headers for the listviewitems, but when I try to set it with the commented setter, the name does not get displayed.

    Below you can see the (stripped) XAML for my ListView:

    <telerik:RadTreeView ItemsSource="{Binding Items}">
                                
                   <telerik:RadTreeView.ItemContainerStyle>
                       <Style TargetType="telerik:RadTreeViewItem">
                           <!--<Setter Property="Header" Value="{Binding Path=Item, Converter={StaticResource ClientTreeItemToTextConverter}}"/>-->
                           <Setter Property="IsDropAllowed" Value="{Binding IsDropAllowed, Mode=TwoWay}"/>
                           <Setter Property="IsLoadOnDemandEnabled" Value="{Binding IsLoadOnDemandEnabled, Mode=TwoWay}"/>
                           <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                           <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                        </Style>
                   </telerik:RadTreeView.ItemContainerStyle>
     
                   <telerik:RadTreeView.ItemTemplate>
                       <HierarchicalDataTemplate ItemsSource="{Binding Children}">
                           <StackPanel Orientation="Horizontal" Margin="2">
                               <Image Margin="0 0 4 0" Source="{Binding Path=Item.Type, Converter={StaticResource NodeTypeToImageConverter}}" VerticalAlignment="Center"/>
                               <TextBlock Text="{Binding Path=Item, Converter={StaticResource ClientTreeItemToTextConverter}}" VerticalAlignment="Center"/>
                           </StackPanel>
                       </HierarchicalDataTemplate>
                   </telerik:RadTreeView.ItemTemplate>
     
              </telerik:RadTreeView>
  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 18 Aug 2011 Link to this post

    Hi Matthias,

     Similarly to the use of GetItemByPath() method, you have to set telerik:TextSearch.TextPath attached property to indicate which property ( from the ViewModel) to be used as a path segment. Unfortunately, in your case you don't use string property in your ViewModel to bind the Header and you use Converter. Is it possible for you to re-factor your ViewModel to use such string property ?

    Greetings,
    Petar Mladenov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  3. UI for WPF is Visual Studio 2017 Ready
  4. Matthias
    Matthias avatar
    26 posts
    Member since:
    Apr 2011

    Posted 18 Aug 2011 Link to this post

    Hi,

    thanks for your fast reply.
    Introducing a string property ist no problem, but where do I have to set telerik:TextSearch.TextPath ?
    Within <telerik:RadTreeView.ItemContainerStyle>
    ...
    </telerik:RadTreeView.ItemContainerStyle>
    ?

     

     

     

     

  5. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 23 Aug 2011 Link to this post

    Hi Matthias,

     You have to set it in the RadTreeView's declaration as an attached property:

    <telerik:RadTreeView telerik:TextSearch.TextPath="Header">
    ...
    </telerik:RadTreeView>

    All the best,
    Petar Mladenov
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Back to Top