Conventions for LongListSelector in WP7 toolkit?

Feb 13, 2011 at 4:40 PM

The LongListSelector control in WP7 Silverlight Toolkit used some complex methods to render its items. It didn't derive from Selector or ItemsControl. I read the documentation of conventions but had no idea how to make this work.

And about its ListHeaderTemplate, LongListSelector also used its own way to render that, so binding didn't work either. Setting the ListHeader directly seemed to be working but it would crash under certain circumstances (it's its own issue though).

Has anyone tried to implement the convention for LongListSelector? Any suggestions would be great.


Feb 14, 2011 at 12:05 PM

With LongListSelector didn't seem to work. Then I tried to do the list-header with normal listbox.

However, attaching the View.Model property in the style didn't work. This would go into a runtime error. Said "Unknown namespace". But I did include the namespace.

Here's the code:


    <Style x:Key="HeaderListBox" TargetType="ListBox">
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/>
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="Padding" Value="0"/>
        <Setter Property="Template">
                <ControlTemplate TargetType="ListBox">
                        <ScrollViewer x:Name="ScrollViewer"
                                      BorderBrush="{TemplateBinding BorderBrush}"
                                      BorderThickness="{TemplateBinding BorderThickness}"
                                      Background="{TemplateBinding Background}"
                                      Foreground="{TemplateBinding Foreground}"
                                      Padding="{TemplateBinding Padding}">
                                <ContentControl x:Name="ListHeader" cal:View.Model="{Binding ListHeader}" />

<ListBox x:Name="Items" ItemsSource="{Binding Items}"
         Style="{StaticResource HeaderListBox}">