Stretching the content of a treeview item

6 posts, 0 answers
  1. Matt
    Matt avatar
    7 posts
    Member since:
    Jul 2011

    Posted 26 Sep 2011 Link to this post

    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
  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 29 Sep 2011 Link to this post

    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 >>

  3. DevCraft banner
  4. Matt
    Matt avatar
    7 posts
    Member since:
    Jul 2011

    Posted 29 Sep 2011 Link to this post

    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();
  5. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 04 Oct 2011 Link to this post

    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 >>

  6. Matt
    Matt avatar
    7 posts
    Member since:
    Jul 2011

    Posted 05 Oct 2011 Link to this post

    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.
  7. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 10 Oct 2011 Link to this post

    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 >>

Back to Top
DevCraft banner