3

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 Answers 2

0

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

or

You can get it using Gesture Tap event.

1
-1

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.

1
  • I'm using MVVM so I can't access productList, it's not in my ViewModel. And especially with Caliburn.Micro, you can't, even if you'd want to. Sep 11, 2013 at 12:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.