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

Stretching the content of a treeview item

5 Answers 130 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 2
Matt asked on 26 Sep 2011, 01:27 PM
I'm trying to display several buttons along side the text for a treeview item.

however the buttons appear directly next to the text instead of to the right as they should be, (see Attached Image)

I've found the following topic which seems to be exactly what i need however it doesn't work. 
http://www.telerik.com/community/forums/silverlight/treeview/how-to-stretch-item-horizontally.aspx

Here is my XAML Code for my tree view. I've set the background to check that the target type was correct and to see what space the item takes up.

<telerik:RadTreeView ItemsSource="{Binding ReportData}"
                     ItemTemplate="{StaticResource ReportDataTreeTemplate}"                                        
                     SelectedItem="{Binding SelectedReport,Mode=TwoWay}">
    <telerik:RadTreeView.ItemContainerStyle>
        <Style TargetType="telerik:RadTreeViewItem">
            <Setter Property="Background" Value="Cornsilk"/>
            <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
         </Style>
    </telerik:RadTreeView.ItemContainerStyle>
</telerik:RadTreeView>

this is the code for my item template

<telerik:HierarchicalDataTemplate x:Key="ReportDataTreeTemplate"
                                  ItemsSource="{Binding Reports}"
                                  ItemTemplate="{StaticResource Reports}">               
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="Auto"/>
        </Grid.ColumnDefinitions>
        <TextBlock Text="{Binding Group.Name}" Grid.Column="0"/>
         
        <telerik:RadButton x:Name="EditButton"
                           Command="{Binding DataContext.EditCommand, ElementName=ReportsTab}"
                           CommandParameter="{Binding Title}"
                           Grid.Column="1">
        </telerik:RadButton>
         
        <telerik:RadButton x:Name="DeleteButton"
                           Command="{Binding DataContext.DeleteReportGroupCommand, ElementName=ReportsTab}"
                           CommandParameter="{Binding Group}"
                           Grid.Column="2">
        </telerik:RadButton>
         
        <telerik:RadButton x:Name="HideButton"
                           Command="{Binding DataContext.HideReportGroupCommand, ElementName=ReportsTab}"
                           CommandParameter="{Binding Group}"
                           Grid.Column="3">                   
        </telerik:RadButton>
    </Grid>
</telerik:HierarchicalDataTemplate>

Setting the grid to stretch also doesn't make any difference. Is it possible to make the content stretch to fill all available space? 

Thanks,

Matt

5 Answers, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 29 Sep 2011, 01:05 PM
Hello Matt,

I wasn't able to reproduce this issue. Can you please have a look at the attached sample and let me know if it works for you or if I am missing something? Thank you in advance for your cooperation.

Regards,
Tina Stancheva
the Telerik team

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

0
Matt
Top achievements
Rank 2
answered on 29 Sep 2011, 04:12 PM
Thanks for the reply, the sample that you sent me works correctly and is exactly what I'm after.

Since your sample worked and my project doesnt, I started adding to the sample to see what part broke it. Setting the theme to Metro within the app.xaml breaks the sample project for me.

StyleManager.ApplicationTheme = new MetroTheme();
0
Tina Stancheva
Telerik team
answered on 04 Oct 2011, 02:51 PM
Hi Matt,

I am still having troubles reproducing this issue. I tried setting the Metro theme as application theme in the App class constructor but still the buttons are properly aligned:
public App()
{
    this.Startup += this.Application_Startup;
    this.Exit += this.Application_Exit;
    this.UnhandledException += this.Application_UnhandledException;
 
    StyleManager.ApplicationTheme = new MetroTheme();
 
    InitializeComponent();
}

Can you attach a solution where the issue can be reproduced so that we can further investigate it? Thank you in advance.

Kind regards,
Tina Stancheva
the Telerik team

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

0
Matt
Top achievements
Rank 2
answered on 05 Oct 2011, 10:05 AM
Thanks for the modified project, that one also works, however if I change the references assemblies so that the DLL's on my system are used and not the ones supplied with the project, then the problem comes back.

I did a manual update and it seems to be working in the test application again, what annoys me is that Telerik did an automatic update on my machine recently and that didn't fix the problem, so I assumed I was using the latest version.

Haven't been able to test this on my actual application as updating to the lastest version has broken something within the telerik popup window host.
0
Tina Stancheva
Telerik team
answered on 10 Oct 2011, 08:59 AM
Hi Matt,

Thanks for getting back to us. Indeed I tested the issue with the latest official release - Q2 2011 SP1 (version 2011.2.0920). So if you upgrade to that version and you still have issues, please let us know.

Also, if we can assist you in any other way during the upgrade please let us know.

All the best,
Tina Stancheva
the Telerik team

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

Tags
TreeView
Asked by
Matt
Top achievements
Rank 2
Answers by
Tina Stancheva
Telerik team
Matt
Top achievements
Rank 2
Share this question
or