locked
Problem in accessing Data template from code RRS feed

  • Question

  • Hi ,

    Initially my page has only one data template and i was accessing data template using this code

    DataTemplate data = this.Resources.Values.OfType<DataTemplate>().First();

    but when i try to add second data template after the first data template in xaml markup. The items is no longer to see in long list selector but when i click any where i shows another page with that item clicked details but it doenst show items.

    code runs fine when only one data template is available. and even doesnt work when only second code is installed in xaml code (not c#)

    im placing the second data template like this

     <phone:PhoneApplicationPage.Resources>
            <DataTemplate x:Key="template">
               
                    <StackPanel Orientation="Vertical" Width="auto" Margin="0,20,0,0" Height="auto">
                        
                        <TextBlock Name="NewsTitle"  Text="{Binding Title}"  Width="auto" Height="auto" TextWrapping="Wrap" FontFamily="Trebuchet MS" FontSize="{StaticResource PhoneFontSizeMediumLarge}" />
                        <TextBlock Name="NewsDate"  Text="{Binding PublishDate}"  Width="auto" Height="auto" TextWrapping="Wrap"  FontSize="{StaticResource PhoneFontSizeSmall}" />
    
                </StackPanel>
                
            </DataTemplate>
    
            <DataTemplate x:Key="sections" >
    
                <StackPanel Orientation="Vertical" Width="auto" Margin="0,20,0,0" Height="auto">
    
                    <TextBlock Name="SectionTitle"  Text="{Binding Name}"  Width="auto" Height="auto" TextWrapping="Wrap" FontFamily="Trebuchet MS" FontSize="{StaticResource PhoneFontSizeMediumLarge}" />
    
    
                </StackPanel>
    
            </DataTemplate>
        </phone:PhoneApplicationPage.Resources>


    Thank You , Shan Ali Khan


    • Edited by Shan Khan Wednesday, December 18, 2013 2:04 PM
    Wednesday, December 18, 2013 10:39 AM

Answers