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

How to position content in HeaderTemplate of TileViewItem

1 Answer 70 Views
TileView
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 25 Feb 2012, 12:53 PM
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

1 Answer, 1 is accepted

Sort by
0
Kiril Stanoev
Telerik team
answered on 27 Feb 2012, 01:44 PM
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 >>
Tags
TileView
Asked by
Scott
Top achievements
Rank 1
Answers by
Kiril Stanoev
Telerik team
Share this question
or