Binding with HEader Template.

2 posts, 0 answers
  1. Cristovao
    Cristovao avatar
    24 posts
    Member since:
    Jun 2012

    Posted 21 Mar 2012 Link to this post

    I have my List like this:

    <telerikPrimitives:RadDataBoundListBox  Margin="12,0"
       x:Name="lbMainNews"
                              ItemsSource="{Binding News.News}"
                                        ItemTemplate="{StaticResource NewsItemTemplate}" 
                                        Tap="lbNews_Tap"
                                        telerikCore:InteractionEffectManager.IsInteractionEnabled="True" >
                                <telerikPrimitives:RadDataBoundListBox.ListHeaderTemplate>
                                    <DataTemplate>
                                        <Grid Name="GridHeader"
                                          Margin="0,0,0,12" Height="150"
                                           DataContext="{Binding DataContext}" Tap="GridHeader_Tap">
     
                                            <Image Width="430" Margin="0,0,0,0"  Stretch="UniformToFill" >
                                                <Image.Source>
                                                    <BitmapImage  CreateOptions="{StaticResource CreateOption}" UriSource="{Binding MainImage.Img}"/>
                                                </Image.Source>
                                            </Image>
                                            <StackPanel VerticalAlignment="Bottom" >
                                                <StackPanel.Background>
                                                    <SolidColorBrush Color="{StaticResource PhoneBackgroundColor}" Opacity="0.5"/>
                                                </StackPanel.Background>
                                                <TextBlock TextWrapping="Wrap"  Text="{Binding MainArticle.DatePub}" Foreground="White" Margin="12,0,12,0"  Style="{StaticResource PhoneTextTitle3Style}"/>
                                                <TextBlock TextWrapping="Wrap"  Text="{Binding Title}" Style="{StaticResource PhoneTextTitle3Style}" Foreground="White" Margin="12,0,12,0"/>
                                            </StackPanel>
                                        </Grid>
                                    </DataTemplate>
                                </telerikPrimitives:RadDataBoundListBox.ListHeaderTemplate>
     
                                <telerikPrimitives:RadDataBoundListBox.EmptyContentTemplate>
                                    <DataTemplate>
                                        <TextBlock Style="{StaticResource PhoneTextLargeStyle}" Text=" "/>
                                    </DataTemplate>
                                </telerikPrimitives:RadDataBoundListBox.EmptyContentTemplate>
     
     
                                <telerikPrimitives:RadDataBoundListBox.ListFooterTemplate>
                                    <DataTemplate>
                                        <Grid Height="70" Background="Transparent"></Grid>
                                    </DataTemplate>
                                </telerikPrimitives:RadDataBoundListBox.ListFooterTemplate>
                            </telerikPrimitives:RadDataBoundListBox>


    Now the itemsource is easy and works well

    The object has News.News = collection on lines
    and also News.MainArticle = object with one Article...

    My dificulty is how do I bind the header template
  2. Cristovao
    Cristovao avatar
    24 posts
    Member since:
    Jun 2012

    Posted 23 Mar 2012 Link to this post

    Found the answer... sooo easy!

    <telerikPrimitives:RadDataBoundListBox  Margin="0"
                                                           x:Name="lbMainNews"
                                                           ItemsSource="{Binding News.News}"
                                   ItemTemplate="{StaticResource NewsItemTemplateInPivot}"
                                   ListHeaderTemplate="{StaticResource NewsList_HeaderTemplate}" 
                                   ListHeaderContent="{Binding News.MainArticle}"
                                   Tap="lbNews_Tap"
                                   telerikCore:InteractionEffectManager.IsInteractionEnabled="True" >

    just used 

      ListHeaderTemplate="{StaticResource NewsList_HeaderTemplate}"  
      ListHeaderContent="{Binding News.MainArticle}"
  3. DevCraft banner
Back to Top