How to access the UI Element present inside the data template in metro apps? RRS feed

  • Question

  • Hi all,

    <DataTemplate x:Key="StandardMyTemplate">
            <Grid Height="110" Margin="6">
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                <Border Background="{StaticResource ListViewItemPlaceholderBackgroundThemeBrush}" Width="110" Height="110">
                    <Image Source="{Binding Image}" Stretch="UniformToFill"/>
                <StackPanel Grid.Column="1" VerticalAlignment="Top" Margin="10,0,0,0">
                    <TextBlock x:Name = "Title" Text="{Binding Title}" Style="{StaticResource TitleTextStyle}" TextWrapping="NoWrap"/>
                    <TextBlock  x:Name = "Subtitle" Text="{Binding Subtitle}" Style="{StaticResource CaptionTextStyle}" TextWrapping="NoWrap"/>
                    <TextBlock x:Name = "Description"Text="{Binding Description}" Style="{StaticResource BodyTextStyle}" MaxHeight="60"/>

    Just i need to update the Title (Textbox) value from c# ( ie itemDetailpage.xaml ).
    Atcually i tried below two way code :

    var itemName = Application.current.resource["Title"] as Textbox;
    string text = "hello";
    itemName.text = text;

    second way :


    in this above site ,author followed three approaches..but it is not working properly for me ...i think i`m missing something .please help me out how to access the UI element that present inside the data template ?

    Thanks in Advance

    Lavanya S

    Tuesday, April 30, 2013 4:15 AM


  • go through this links



    you may get some solution.

    Please remember to mark the replies as answers it will help others too.

    • Edited by RishiRajIT Tuesday, April 30, 2013 6:17 AM
    • Proposed as answer by RishiRajIT Tuesday, April 30, 2013 6:17 AM
    • Marked as answer by SparkleLavs Thursday, May 2, 2013 1:04 PM
    Tuesday, April 30, 2013 5:49 AM