문제

I'm using Caliburn.Micro and the LongListSelector. Because binding SelectedItem is a problem i'm create a Custom class

public static readonly DependencyProperty SelectedItemProperty = DependencyProperty.Register("SelectedItem", typeof(object), typeof(LongListSelector), new PropertyMetadata(null, OnSelectedItemChanged));

Problem is, after returning to the list, when I click the same item again, it is already selected and not works.

I'm used a TAP event instead SelectionChanged and it Works but in my longlistselector i use a Grouping and Tap event click if i tap on group.

Help me!

도움이 되었습니까?

해결책

I Solved!! My problem was in a DependecyProperty declaration

private static void OnSelectedItemChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        var selector = (LongListSelector)d;
        selector.SelectedItem = e.NewValue;
    }

NOT WORKS

WORKS This declaration

 private static void OnSelectedItemChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        var selector = (LongListSelector)d;
        selector.SetSelectedItem(e);
    }

    private void SetSelectedItem(DependencyPropertyChangedEventArgs e)
    {
        base.SelectedItem = e.NewValue;
    }

다른 팁

Setting SelectedItem=null in OnActivate in your ViewModel should do the trick.

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