2

I create dynamically ModernTab in the code behind with their informations (DisplayName and URI source).

Initialization of the ModernTab:

<Grid Style="{StaticResource ContentRoot}">
    <mui:ModernTab Layout="List" Name="listEcole"
                   PreviewMouseLeftButtonUp="ModTab_PreviewMouseLeftButtonUp"/>
</Grid> 

Code behind :

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) 
    }); 
}

My problem is that i want to know the DisplayName of the selected link to put it in a property and use it in another UserControl.

Machavity
  • 30,841
  • 27
  • 92
  • 100
281
  • 59
  • 5

1 Answers1

0

Try this:

var selectedLink = listEcole.Links.FirstOrDefault(x => x.Source == listEcole.SelectedSource);
if (selectedLink != null)
{
    string selectedDisplayName = selectedLink.DisplayName;
}

It should give you a reference to the currently selected Link in the ModernTab.

mm8
  • 163,881
  • 10
  • 57
  • 88
  • Thanks a lot ! This was exactly what I was looking for. It works and solves my problem ! – 281 Mar 23 '17 at 16:40