mui icon indicating copy to clipboard operation
mui copied to clipboard

Unable to navigate to (...)Settings.xaml, could not find a ModernFrame target ''

Open kgroener opened this issue 10 years ago • 12 comments

When I updated to the newest version of MUI (v1.0.6) I got this error while trying to navigate to the settings tab. Even though the code I used seemed to be the same as used in the MUI demo app.

While debugging though the code I noticed that in the class 'ModernWindow.cs' the 'e.Source' property was used in the OnNavigateLink method. the value of this property was different than from the demo (in the demo it was the ContentFrame from the ModernWindow.xaml, in my project it was the ModernWindow itself). this seemed to cause the code to not be able to find the correct frame, so I tried changing it to 'e.OriginalSource' wich fixed the problem for me.

I'm not sure if this is the correct fix for the problem, but thought you should know.

Kind regards,

Koen

kgroener avatar Feb 27 '15 12:02 kgroener

Not sure I fully understand the issue. Care to share some source code?

kozw avatar Mar 07 '15 20:03 kozw

This was my main modern window xaml file I used wich seemed to caused the problem. The code behind also contains some code, but non of it seems relevant to this problem.

<mui:ModernWindow  x:Class="(...).MainModernWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mui="http://firstfloorsoftware.com/ModernUI"
    ContentSource="/UserControls/Settings/ModernUISettings.xaml"
    Title="Main Window"
    Icon="Icon.ico"
    IsTitleVisible="True"
    Height="900" Width="1000">

    <mui:ModernWindow.LogoData>
        <PathGeometry Figures="(...)" />
    </mui:ModernWindow.LogoData>

    <mui:ModernWindow.TitleLinks>
        <mui:Link DisplayName="Settings" Source="/UserControls/Settings/ModernUISettings.xaml" />
    </mui:ModernWindow.TitleLinks>
</mui:ModernWindow>

I changed the following method in ModernWindow.cs:

    private void OnNavigateLink(object sender, ExecutedRoutedEventArgs e)
        {
            if (this.LinkNavigator != null)
            {
                Uri uri;
                string parameter;
                string targetName;

                if (NavigationHelper.TryParseUriWithParameters(e.Parameter, out uri, out parameter, out targetName))
                {
                    this.LinkNavigator.Navigate(uri, e.Source as FrameworkElement, parameter);
                }
            }
        }

To:

    private void OnNavigateLink(object sender, ExecutedRoutedEventArgs e)
        {
            if (this.LinkNavigator != null)
            {
                Uri uri;
                string parameter;
                string targetName;

                if (NavigationHelper.TryParseUriWithParameters(e.Parameter, out uri, out parameter, out targetName))
                {
                    this.LinkNavigator.Navigate(uri, e.OriginalSource as FrameworkElement, parameter);
                }
            }
        }

kgroener avatar Mar 09 '15 07:03 kgroener

The same happened to me now. I updated ModernUI package from 1.0.5 to 1.0.6 and getting the same error. Is there any other way how to fix it without changing the ModernWindow.cs code?

supermartzin avatar Mar 12 '15 13:03 supermartzin

I'm seeing this too. Unable to navigate via the TitleLinks - anyone found a workaround yet?

5flags avatar Mar 30 '15 09:03 5flags

Happens when the MainWindow.xaml contains any Content-Controls. I added Top/Bottom/LeftSideContent Tags in my fork of MUI to be able to e.g. have a Statusbar / TrayIcon

c0nnex avatar Jul 04 '15 11:07 c0nnex

Same here, I wanted to navigate to help page upon F1 key press but got this error:

<mui:ModernWindow.InputBindings>
        <KeyBinding Key="F1"
                    Command="mui:LinkCommands.NavigateLink"
                    CommandParameter="/Pages/HelpPage.xaml" />
</mui:ModernWindow.InputBindings>

mafshin avatar Jul 11 '15 07:07 mafshin

I have the same problem as c0nnex

As soon as I added the tray icon and the attached logic it, I used wpf Notify Icon and followed it by the book. My WPF app. only crashes when the "settings" tab is clicked.

Happens when the MainWindow.xaml contains any Content-Controls. I added Top/Bottom/LeftSideContent Tags in my fork of MUI to be able to e.g. have a Statusbar / TrayIcon.

Has anyone found a fix for this yet?

Leblarh avatar Jul 27 '15 22:07 Leblarh

having the same issue

MohanVijayakumar avatar Jun 02 '16 11:06 MohanVijayakumar

programmatically navigate to other pages https://mui.codeplex.com/discussions/651493

hemant2380 avatar Jun 06 '16 11:06 hemant2380

I have a problem disappeared after I removed the second closing angle bracket ( > ) at the top, where the descriptions

<mui:ModernWindow x:Class="MyApple.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:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity">

and was so:

<mui:ModernWindow x:Class="MyApple.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:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity">>

Gexon avatar Jul 04 '18 11:07 Gexon

I got the same issue,: I add a "NotifyIcon" in the MainWindow.xaml file, then I build and run, fine for now. But when i click "setting", I got the same exciption with you at the same place.

remove the "NotifyIcon" code, it works just fine. How can i solve a bug like this???

ameaninglessname avatar Nov 13 '18 13:11 ameaninglessname

image

I solved this problem by change the ModernWindow.cs@line155 from:e.Source to: e.OriginalSource

I rebuilded solution and did some simple test: just click almost everything I can click. Navigate shit from shit.

You can know the difference between two variables, I guess there are some "possible System.Windows.RoutedEventArgs.Source adjustment made by class handling" happened which will lead it to crash.

Now everything works fine for now.

ameaninglessname avatar Nov 14 '18 08:11 ameaninglessname