I'm trying to navigate to an XAML control (specifically ModernFrame control) via the following code when a keyboard shortcut is pressed:
LinkNavigator.Navigate(new Uri("/Controls/SettingsManager.xaml", UriKind.Relative), this);
The keyboard shortcut fires and then I am given an exception:
System.ArgumentException: 'Unable to navigate to /Controls/SettingsManager.xaml, could not find a ModernFrame target '''
The following is the source for the SettingsManager as a ModernFrame
--note that this still works if you change it to a UserControl
. I changed it to a ModernFrame
because of the aforementioned exception which is looking for a ModernFrame
.
Now the SettingsManager.xaml
control functions perfectly fine if I navigate to it via a TitleLink within the window. However the moment I try to navigate to it programmatically I receive the exception. You can leave the control completely empty and the exception is still thrown.
SettingsManager.xaml.cs:
using System.Collections.Generic;
using System.Linq;
using System.Windows.Controls;
using FirstFloor.ModernUI.Presentation;
using FirstFloor.ModernUI.Windows.Controls;
using KeystoneEstimating.Containers;
namespace KeystoneEstimating.Controls {
/// <summary>
/// Interaction logic for SettingsManager.xaml
/// </summary>
public partial class SettingsManager : ModernFrame {
public SettingsManager() {
InitializeComponent();
/// Load settings into the Link interface of MUI.
List<AppSettings> settings = AppInfo.SettingsContainers;
foreach (AppSettings set in settings) {
Link lnk = new Link();
lnk.DisplayName = set.SettingsName;
lnk.Source = set.ControlPath;
SettingsLinks.Links.Add(lnk);
}
// Load up the very first registered settings page.
if (SettingsLinks.Links.First() != null)
SettingsLinks.SelectedSource = SettingsLinks.Links.First().Source;
}
}
}
SettingsManage.xaml:
<mui:ModernFrame xmlns:mui="http://firstfloorsoftware.com/ModernUI"
x:Class="KeystoneEstimating.Controls.SettingsManager"
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:local="clr-namespace:KeystoneEstimating"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid Style="{StaticResource ContentRoot}">
<mui:ModernTab Layout="List" Name="SettingsLinks"/>
</Grid>
</mui:ModernFrame>
ModernUI comes in two NugetPackages labeled ModernUI.WPFCore
. One is version 2.0.0
and the other is version 3.1.2
. The problem is reproducible on both.