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

ExpandItemByPath: Set Header

3 Answers 143 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Matthias
Top achievements
Rank 1
Matthias asked on 16 Aug 2011, 10:29 AM

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>

3 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 18 Aug 2011, 01:00 PM
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 >>

0
Matthias
Top achievements
Rank 1
answered on 18 Aug 2011, 03:42 PM
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>
?

 

 

 

 

0
Petar Mladenov
Telerik team
answered on 23 Aug 2011, 03:47 PM
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 >>

Tags
TreeView
Asked by
Matthias
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Matthias
Top achievements
Rank 1
Share this question
or