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!
You should use
SelectedSource="{Binding SelectedYear.Source}"
in your xaml.