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

TreeListView - CellTemplate & ItemTemplate (Both appear when I click on a tree element)

1 Answer 148 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Rogério Ferreira
Top achievements
Rank 1
Rogério Ferreira asked on 26 Mar 2010, 02:03 PM
(Opened a support ticket with this information and with a small application to show this behaviour)

Hi,

 I'm having what I think is a strange behaviour, probably is something I'm doing wrong.

 As I stated in the thread title, when I click on a tree item both cellTemplate and ItemTemplate appear, so If I click on an item two lines appear, the 1st being the CellTemplate representation and the 2nd line the ItemTemplate representation. (attch: double.jpg).

 This is the code that I'm using:

<UserControl.Resources> 
        <admConverter:MulticastTreeItemImageConverter x:Name="treeItemConverter"/> 
        <admConverter:MulticastTreeItemValueConverter x:Name="treeItemValueConverter"/> 
         
        <DataTemplate x:Key="fieldTemplate"
            <StackPanel Orientation="Horizontal"
                <Image Source="{Binding Converter={StaticResource treeItemConverter}}" Margin="0,0,6,0" /> 
                <TextBlock Text="{Binding Name}" Margin="2"/> 
            </StackPanel> 
        </DataTemplate> 
         
        <DataTemplate x:Key="fieldValueTemplate"
            <StackPanel Orientation="Horizontal"
                <TextBlock Text="{Binding Converter={StaticResource treeItemValueConverter}}" Margin="2"/> 
            </StackPanel> 
        </DataTemplate> 
         
        <telerikControls:HierarchicalDataTemplate x:Key="messageTemplate" ItemsSource="{Binding Value.MessageFields}"
            <StackPanel Orientation="Horizontal"
                <Image Source="/Cmf.Presentation.Framework.Core.Controls;component/Images/Generic/folder-16x16.png" Margin="0,0,6,0" /> 
                <TextBlock Text="{Binding Name}" Margin="2"/> 
            </StackPanel> 
        </telerikControls:HierarchicalDataTemplate> 
         
        <l:TreeMessageTemplateSelector  
            x:Key="treeTemplateSelector"  
            FieldTemplate="{StaticResource fieldTemplate}"  
            MessageTemplate="{StaticResource messageTemplate}"/> 
         
    </UserControl.Resources> 
    <Grid x:Name="LayoutRoot"
        <telerikNavigation:RadTreeListView 
            Margin="3" 
            x:Name="tree" 
            ItemTemplateSelector="{StaticResource treeTemplateSelector}" 
            > 
            <telerikNavigation:RadTreeListView.Columns> 
                <telerikNavigation:RadColumn CellTemplate="{StaticResource fieldTemplate}"  PropertyName="Name" Header="Name"/> 
                <telerikNavigation:RadColumn CellTemplate="{StaticResource fieldValueTemplate}" PropertyName="Value" Header="Value"/> 
            </telerikNavigation:RadTreeListView.Columns> 
        </telerikNavigation:RadTreeListView> 
    </Grid> 

I'm using HierarchicalDataTemplate to be able to show a object that has several levels.

Message X
 - Field A
 - Field B
 - Message Y
    - Field C 
    - Field D

Thanks ahead for all the help,

Rogério Ferreira
 

1 Answer, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 29 Mar 2010, 03:07 PM
Hi Rogério Ferreira,

I answered the support ticket you opened, still I'd like to post the answer here as well.

The described behavaior is expected, because the ItemTemplate is used as a details template for each row.  Therefore, when the ItemTemplate specifies which properties to be displayed in a certain way,  this properties will appear bellow the selected item as details.

If you don't want to display details for the rows, you can simply leave the ItemTemplate empty.

Sincerely yours,
Tina Stancheva
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
TreeListView
Asked by
Rogério Ferreira
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Share this question
or