Question

I've managed to get the LongListSelector running through MVVM. In other words the ItemSource is set through a property on my viewmodel.

But for some weird reason, I can't seem to be able to 'bind' the SelectedItem of the LongListSelector... I'm not getting in the Set nor Get of the ViewModel property. How is this done? And what should the 'type' of the SelectedItem on the ViewModel be? I thought the Type of the Class inside the Group?

My current xaml:

<silverlighttoolkit:LongListSelector x:Name="AlbumsList"
                                        Background="Transparent"
                                        ItemTemplate="{StaticResource ItemTemplate}"
                                        GroupHeaderTemplate="{StaticResource GroupHeaderTemplate}"
                                        GroupItemTemplate="{StaticResource GroupItemTemplate}"
                                        ItemsSource="{Binding GroupedAlbums}"
                                        SelectedItem="{Binding SelectedAlbum, Mode=TwoWay}">
    <silverlighttoolkit:LongListSelector.GroupItemsPanel>
        <ItemsPanelTemplate>
            <silverlighttoolkit:WrapPanel />
        </ItemsPanelTemplate>
    </silverlighttoolkit:LongListSelector.GroupItemsPanel>
</silverlighttoolkit:LongListSelector>
Was it helpful?

Solution

Use the SelectionChanged event. Either though a EventToCommand behaviour, or a attached behaviour.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top