1

I'm binding ModernTab.Links to a LinkCollection and want the first Link to be selected by default. This works if I hardcode it:

<mui:ModernTab Layout="List" Links="{Binding Years}" SelectedSource="hard-coded-uri"/>

The LinkCollection wont be static so I set SelectedSource to a new Property "SelectedYear" from my ViewModel:

<mui:ModernTab Layout="List" Links="{Binding Years}" SelectedSource="{Binding SelectedYear}"/>

"SelectedYear" is the first link in the LinkCollection "Years":

SelectedYear = Years.First();

I can verify that "SelectedYear" is the first link and I would have bet 100€ that this would work .. but it doesn't. No year is selected. I've defined the property SelectedYear like this:

    private Link _selectedYear { get; set; }
    public Link SelectedYear
    {
        get
        {
            return _selectedYear;
        }
        set
        {
            _selectedYear = value;
            OnPropertyChanged("SelectedYear");
        }
    }

Where is the flaw? Any help is appreciated!

peter
  • 2,103
  • 7
  • 25
  • 51

2 Answers2

3

You should use

SelectedSource="{Binding SelectedYear.Source}"

in your xaml.

gaborhodi
  • 164
  • 7
0

In your XAML, set Listview's SelectedIndex property to zero.

That will be your default list item.

Scott Nimrod
  • 11,206
  • 11
  • 54
  • 118