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

Setting backcontent programmatically

1 Answer 65 Views
HubTile
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Paul
Top achievements
Rank 1
Paul asked on 20 May 2012, 06:25 AM
I'd like to set the text in a textblock in backcontent through code-behind. How do I do this? Here is my XAML:

<telerikPrimitives:RadHubTile Message="" Height="171" Name="tileToday" Title="Tile Title" VerticalContentAlignment="Bottom" VerticalAlignment="Bottom"  Background="{StaticResource PhoneAccentBrush}" Width="171">
    <telerikPrimitives:RadHubTile.BackContent>
        <Border Background="{StaticResource PhoneAccentBrush}">
            <TextBlock Margin="6,6,6,6" TextWrapping="Wrap" HorizontalAlignment="Center"
    VerticalAlignment="Center"
    Text="** What I'd like to change **"/>
        </Border>
    </telerikPrimitives:RadHubTile.BackContent>
</telerikPrimitives:RadHubTile>

1 Answer, 1 is accepted

Sort by
0
Victor
Telerik team
answered on 21 May 2012, 08:49 AM
Hello Paul,

Thanks for the question.
Since the back content of the hub tile is inside a data template, you will not have an auto-generated field if you set x:Name to your text block. In order to do it, you need to find the text block manually. Fortunately this case occurs a few times in our controls so we have a class that does just that. Assuming your hub tile is named hubTile and the text block in the back content named textBlock, to find the text block you have to do this:

TextBlock textBlock = ElementTreeHelper.FindVisualDescendant<TextBlock>(this.hubTile, (child) => (child as FrameworkElement).Name == "textBlock");

It is important to note that this code example will only work after the layout algorithm of the hub tile has passed because in Silverlight, DataTemplate objects are loaded during layout.

Please write again if you need further assistance.

Kind regards,
Victor
the Telerik team

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

Tags
HubTile
Asked by
Paul
Top achievements
Rank 1
Answers by
Victor
Telerik team
Share this question
or