How to position content in HeaderTemplate of TileViewItem

2 posts, 0 answers
  1. Scott
    Scott avatar
    4 posts
    Member since:
    Jan 2012

    Posted 25 Feb 2012 Link to this post

    Hey there - 

    I am using ContainerBindings with an ItemTemplate to set my HeaderTemplate on my RadTileView. The Tiles are being bound to an ObservableCollection<Tiles> in my viewmodel. My Tiles class exposes a Header property which is a simple string that contains the text to display. Works fine. I want to include some custom buttons in the header (add/edit/delete). First, I figured I'd just change my DataTemplate like so (not a precise example, more for demonstration): 

    <DataTemplate x:Key="TileHeaderTemplate" telerik:ContainerBinding.ContainerBindings="{StaticResource ContainerBindingCollection}">
        <StackPanel x:Name="StackWrap" Orientation="Horizontal">
            <TextBlock Text="{Binding Header}" />
            <StackPanel x:Name="StackButtons" Orientation="Horizontal">
                <Button Content="Add" />
                <Button Content="Edit" />
                <Button Content="Delete" />
            </StackPanel>
        </StackPanel>
    </DataTemplate>

    While this displayed my buttons, it didn't quite work as I expected. The width of my wrapper StackPanel was only as wide as the content. What I desire is to have my Add/Edit/Delete on the far right of the header. I played with different elements (stack vs grid etc) and HorizontalAlignments, but no avail.

    So I read an article from y'all that described having to edit the ControlTemplate, which allowed me to actually place them right up next to the min/max buttons. Ideal. I *did* do that successfully, but your themes don't work with anything but the defaults, so I lost all styling. I eventually pulled out the XAML from the Metro theme but wasn't seeing my buttons show up even after editing. I'm assuming this is because I'm still applying the theme globally to my app, so it's not taking my local style (defined in RadTimeBarStyle.xaml resource dictionary). What gives? Is there a way to right-align the content within a DataTemplate?

    Thanks,

    Scott
  2. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1512 posts

    Posted 27 Feb 2012 Link to this post

    Hi Scott,

    Could you please take a look at the attached project and let me know if this works for you. I'd be glad to further assist you.

    All the best,
    Kiril Stanoev
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. DevCraft banner
Back to Top