我得到了这个ConfigurationUserCOntrol
<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"
>
<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:Link x:Name="SpecieDetails" DisplayName="Species Details" />
</mui:ModernTab.Links>
</mui:ModernTab>
</Grid>
</UserControl>
然后在代码中,我得到了这个
private void ModTab_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
SpecieDetails.Source = new Uri("pack://application:,,,/BreedList.xaml", UriKind.Relative);
}
它说我有一个URI格式异常。我做错了什么?
我想清除BreedListV2.xaml并将其替换为另一个UserCOntrol,但这种URI格式异常让我这样做。
答案 0 :(得分:1)
那是Absolute
Uri而不是Relative
<强>绝对强>
SpecieDetails.Source = new Uri("pack://application:,,,/BreedList.xaml", UriKind.Absolute);
<强>相对强>
SpecieDetails.Source = new Uri("/BreedList.xaml", UriKind.Relative);
将上述代码设置为UriKind.Absolute
应该可以正常工作