C# WPF确定我单击的链接

C# WPF确定我单击的链接,c#,wpf,modern-ui,C#,Wpf,Modern Ui,我在这里得到了一个标记: <UserControl x:Class="NeoClinic.MAS.ConfigurationsList" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://s

我在这里得到了一个标记:

<UserControl x:Class="NeoClinic.MAS.ConfigurationsList"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:mui="http://firstfloorsoftware.com/ModernUI"
             mc:Ignorable="d" 
             x:Name="ConfigControl">
    <Grid Style="{StaticResource ContentRoot}">
        <!-- TODO: set @SelectedSource -->
        <mui:ModernTab x:Name="ModTab" Layout="List"  PreviewMouseLeftButtonUp="ModTab_PreviewMouseLeftButtonUp"> 
            <mui:ModernTab.Links >
                <!-- TODO: set @Source -->
                <mui:Link x:Name="BreedLink" DisplayName="Breeds" Source="/Pages/BreedListV2.xaml" />
                <mui:Link x:Name="SpecieLink" DisplayName="Species" Source="/Pages/SpeciesList.xaml" />
            </mui:ModernTab.Links>

        </mui:ModernTab>
    </Grid>
</UserControl>
那么,如何确定单击了哪个链接,以便在单个链接中加载不同的用户控件呢

if(what I clicked == Breeds)
{
    BreedLink.Source = new Uri("/BreedList.xaml", UriKind.Relative);
}
else if (what I clicked == BreedsDetails)
{
    BreedLink.Source = new Uri("/BreedDetails.xaml", UriKind.Relative);
}

或者有没有其他更简单的方法来实现这一点,比如标记绑定?

您可以查看
OriginalSource
以查看像这样单击的链接:

private void ModTab_PreviewMouseLeftButtonUp(object sender,
                                             MouseButtonEventArgs e)
{
   FrameworkElement link = e.OriginalSource as FrameworkElement;
   if(link != null)
   {
      if(link.Name == "BreedLink")
      {
         ......
      }
      else if (link.Name == "SpecieLink")
      {
         ......
      }
   }
}

你能检查一下发送者是什么吗?
private void ModTab_PreviewMouseLeftButtonUp(object sender,
                                             MouseButtonEventArgs e)
{
   FrameworkElement link = e.OriginalSource as FrameworkElement;
   if(link != null)
   {
      if(link.Name == "BreedLink")
      {
         ......
      }
      else if (link.Name == "SpecieLink")
      {
         ......
      }
   }
}