I encounter some issues with my project. I have a moderntab that I fill of link by a request into a database. The result of my request return a list of string that will be the displayname of the link of my moderntab. I create all the link in behind code, and I want that when I click into a link, the content of the usercontrol change in function of the displayname.
Currently, I know how to take the displayname when the it detect that I change source. But I want to have the same Source for all the link, and the content of the usercontrol change in function of the displayname of the selected link.
That's my xaml code of the moderntab :
<Grid Style="{StaticResource ContentRoot}">
<mui:ModernTab Layout="List" Name="listEcole" SelectedSourceChanged="listEcole_SelectedSourceChanged"/>
</Grid>
That's is the code behind :
public ListEcoles()
{
InitializeComponent();
List<string> listEcoles = MainWindow._RE.ListEcoles();
foreach (string nomEcole in listEcoles)
listEcole.Links.Add(new Link() { DisplayName = nomEcole, Source = new Uri("/Controles/EcoleControl.xaml", UriKind.Relative) });
}
private void listEcole_SelectedSourceChanged(object sender, SourceEventArgs e)
{
var selectedLink = listEcole.Links.FirstOrDefault(x => x.Source == listEcole.SelectedSource);
if (selectedLink != null)
{
string selectedDisplayName = selectedLink.DisplayName;
MessageBox.Show(selectedDisplayName);
}
}
It doesn't work here because every sources of my link are the same, so the event never proceed.
Can some one help me please.