3
votes

I'm using Caliburn.Micro and the LongListSelector. Because binding SelectedItem is a problem I act on the SelectionChanged event. Problem is, after returning to the list, when I click the same item again, it is already selected. So the event doesn't fire. I could set the SelectedIndex to -1 or something, but in Caliburn.Micro I can't access UI controls. That's the point of MVVM, isn't it?! :)

Here's my XAML

<LongListSelector x:Name="NewsItems" 
ItemsSource="{Binding NewsItems}" 
cal:Message.Attach="[Event SelectionChanged] = [NavigateToArticle($eventArgs)]" />

How to solve this? How can I reset the SelectedItem when I can't access the LongListSelector from code?

Thanks!

2

2 Answers

0
votes

You have to put your LongListSelector SelctionMode="Multiple",

or

You can get it using Gesture Tap event.

-1
votes

Did not understood real problem but I think you can solve your problem if selection change event fire every time when user select item-

    private void productList_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        LongListSelector productList= (LongListSelector)sender;
        if (productList.SelectedItem == null)
            return;

        //Write your code here

        //For Tapping many times..
        productList.SelectedItem = null;
    }

The above code will make selection change event to fire on selection of same item every time.