This project is read-only.

Problem with navigation

Aug 21, 2014 at 2:42 PM
Edited Aug 21, 2014 at 2:42 PM
Hi,

my MainWindow looks like this:
<mui:ModernWindow.TitleLinks>
    <mui:Link DisplayName="Settings" Source="/Views/Settings.xaml" />
    <mui:Link DisplayName="Help" Source="http://mui.codeplex.com" />
</mui:ModernWindow.TitleLinks>
<mui:ModernWindow.MenuLinkGroups>
    <mui:LinkGroup DisplayName="Main menu" >
        <mui:LinkGroup.Links>
            <mui:Link DisplayName="Log" Source="/Views/Log.xaml" />
            <mui:Link DisplayName="Settings" Source="/Views/Settings.xaml" />
        </mui:LinkGroup.Links>
    </mui:LinkGroup>
Navigating to the settings page in the main menu works fine, but navigating from the title link throws an exception:

System.ArgumentException was unhandled
HResult=-2147024809
Message=Unable to navigate to /Views/Settings.xaml, could not find a ModernFrame target ''
Source=FirstFloor.ModernUI
StackTrace:
   bei FirstFloor.ModernUI.Windows.Navigation.DefaultLinkNavigator.Navigate(Uri uri, FrameworkElement source, String parameter)
   bei FirstFloor.ModernUI.Windows.Controls.ModernWindow.OnNavigateLink(Object sender, ExecutedRoutedEventArgs e)
   bei System.Windows.Input.CommandBinding.OnExecuted(Object sender, ExecutedRoutedEventArgs e)
   bei System.Windows.Input.CommandManager.ExecuteCommandBinding(Object sender, ExecutedRoutedEventArgs e, CommandBinding commandBinding)
   bei System.Windows.Input.CommandManager.FindCommandBinding(CommandBindingCollection commandBindings, Object sender, RoutedEventArgs e, ICommand command, Boolean execute)
   bei System.Windows.Input.CommandManager.FindCommandBinding(Object sender, RoutedEventArgs e, ICommand command, Boolean execute)
   bei System.Windows.Input.CommandManager.OnExecuted(Object sender, ExecutedRoutedEventArgs e)
   bei System.Windows.UIElement.OnExecutedThunk(Object sender, ExecutedRoutedEventArgs e)
   bei System.Windows.Input.ExecutedRoutedEventArgs.InvokeEventHandler(Delegate genericHandler, Object target)
   bei System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   bei System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   bei System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   bei System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   bei System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   bei System.Windows.Input.RoutedCommand.ExecuteImpl(Object parameter, IInputElement target, Boolean userInitiated)
   bei System.Windows.Input.RoutedCommand.ExecuteCore(Object parameter, IInputElement target, Boolean userInitiated)
   bei MS.Internal.Commands.CommandHelpers.CriticalExecuteCommandSource(ICommandSource commandSource, Boolean userInitiated)
   bei System.Windows.Controls.Primitives.ButtonBase.OnClick()
   bei System.Windows.Controls.Button.OnClick()
   bei System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
   bei System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e)
   bei System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   bei System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   bei System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   bei System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   bei System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
   bei System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
   bei System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   bei System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   bei System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   bei System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   bei System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   bei System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   bei System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   bei System.Windows.Input.InputManager.ProcessStagingArea()
   bei System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   bei System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   bei System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   bei System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   bei System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   bei MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   bei MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   bei System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   bei MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
   bei System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   bei MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   bei MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   bei System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   bei System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   bei System.Windows.Threading.Dispatcher.Run()
   bei System.Windows.Application.RunDispatcher(Object ignore)
   bei System.Windows.Application.RunInternal(Window window)
   bei System.Windows.Application.Run(Window window)
   bei System.Windows.Application.Run()
   bei RedmineLogger.App.Main() in e:\Subversion\v4h-Local\RedmineLogger\RedmineLogger\obj\Debug\App.g.cs:Zeile 0.
   bei System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   bei System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   bei System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   bei System.Threading.ThreadHelper.ThreadStart()
InnerException:

Any quick idea about that? Cannot see any difference to the sample app...

Best regards,
Wilfried
Aug 21, 2014 at 2:52 PM
Do you happen to use a custom Windows style (possible derived from 1.0.5)? If so, make sure you the title link button template contains the following:
<Button Content="{Binding DisplayName}"
  Command="navigation:LinkCommands.NavigateLink"
  CommandParameter="{Binding Source}"
  CommandTarget="{Binding ElementName=ContentFrame}"
  Style="{StaticResource SystemButtonLink}" />
Aug 21, 2014 at 3:01 PM
No, just a plain mainwindow:

<mui:ModernWindow
x:Class="RedmineLogger.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mui="http://firstfloorsoftware.com/ModernUI"
xmlns:tb="http://www.hardcodet.net/taskbar"
Title="MainWindow"
Height="700"
Width="1000"
ContentSource="/Views/Log.xaml"
LogoData="F1 M 24.9015,43.0378L 25.0963,43.4298C 26.1685,49.5853 31.5377,54.2651 38,54.2651C 44.4623,54.2651 49.8315,49.5854 50.9037,43.4299L 51.0985,43.0379C 51.0985,40.7643 52.6921,39.2955 54.9656,39.2955C 56.9428,39.2955 58.1863,41.1792 58.5833,43.0379C 57.6384,52.7654 47.9756,61.75 38,61.75C 28.0244,61.75 18.3616,52.7654 17.4167,43.0378C 17.8137,41.1792 19.0572,39.2954 21.0344,39.2954C 23.3079,39.2954 24.9015,40.7643 24.9015,43.0378 Z M 26.7727,20.5833C 29.8731,20.5833 32.3864,23.0966 32.3864,26.197C 32.3864,29.2973 29.8731,31.8106 26.7727,31.8106C 23.6724,31.8106 21.1591,29.2973 21.1591,26.197C 21.1591,23.0966 23.6724,20.5833 26.7727,20.5833 Z M 49.2273,20.5833C 52.3276,20.5833 54.8409,23.0966 54.8409,26.197C 54.8409,29.2973 52.3276,31.8106 49.2273,31.8106C 46.127,31.8106 43.6136,29.2973 43.6136,26.197C 43.6136,23.0966 46.127,20.5833 49.2273,20.5833 Z">
<mui:ModernWindow.TitleLinks>
    <mui:Link DisplayName="Settings" Source="/Views/Settings.xaml" />
    <mui:Link DisplayName="Help" Source="http://mui.codeplex.com" />
</mui:ModernWindow.TitleLinks>
<mui:ModernWindow.MenuLinkGroups>
    <mui:LinkGroup DisplayName="Main menu" >
        <mui:LinkGroup.Links>
            <mui:Link DisplayName="Log" Source="/Views/Log.xaml" />
            <mui:Link DisplayName="Settings" Source="/Views/Settings.xaml" />
        </mui:LinkGroup.Links>
    </mui:LinkGroup>
    <mui:LinkGroup DisplayName="2nd menu" >
        <mui:LinkGroup.Links>
            <mui:Link DisplayName="Page 1" Source="/Views/Page1.xaml" />
            <mui:Link DisplayName="Page 2" Source="/Views/Page2.xaml" />
            <mui:Link DisplayName="Page 3" Source="/Views/Page3.xaml" />
        </mui:LinkGroup.Links>
    </mui:LinkGroup>
    <mui:LinkGroup DisplayName="Settings" GroupKey="settings">
        <mui:LinkGroup.Links>
            <mui:Link DisplayName="Software" Source="/Views/Settings.xaml" />
        </mui:LinkGroup.Links>
    </mui:LinkGroup>
</mui:ModernWindow.MenuLinkGroups>
<Grid>
    <tb:TaskbarIcon IconSource="/Icons/Main.ico" ToolTipText="hello world" />
</Grid>
</mui:ModernWindow>
Aug 21, 2014 at 3:07 PM
Used Xaml Spy (yes, we love it) to analyze the "Setting" button: It has a CommandParameter: /Views/Settings.xaml. Looks fine...
Aug 21, 2014 at 3:11 PM
When I create a new mui app using the Modern UI WPF Navigation Application template in Visual Studio, and I use the content of your main window, and add the various pages in the Views folder everything seems to work just fine.

How did you create your project?

Good to hear you're using xaml spy :)
Aug 21, 2014 at 3:12 PM
I created the project as a plain WPF app, added (via NuGet) various packages, and changed the main window to be ModernWindow.
Aug 21, 2014 at 3:18 PM
Is that WPF 4.5? Did you follow all steps in this tutorial?
Aug 21, 2014 at 3:40 PM
Double-checked, and yes, it is WPF 4.5, I followed the steps, and I use VS 2013 under Win 8.1
Aug 21, 2014 at 3:59 PM
Ok, found the problem: Did not remove the content of the main window (the grid). When doing that, everything is fine.
Aug 21, 2014 at 4:11 PM
Edited Aug 21, 2014 at 4:11 PM
Interesting. That should not fail (then again Content is not used at all in a default styled ModernWindow)

Anyway, good to hear all is fine
Aug 21, 2014 at 4:19 PM
Thanks for your quick response and support :-)