문제

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>
도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top