Navigate to views in prism containing danish letters

86 views Asked by At

I have views with ÆØÅ in there names. If I try to navigate to one of them I get system.object instead of my view.

unity.RegisterTypeForNavigation();

public static void RegisterTypeForNavigation<T>(this IUnityContainer container)
{
    container.RegisterType(typeof(object), typeof(T), typeof(T).FullName);
}

Should I escape the FullName?

1

There are 1 answers

0
Martin Andersen On

Yes you should url encode the type name, fx. like this

public static class UnityExtensions
{
    public static void RegisterTypeForNavigation<T>(this IUnityContainer container)
    {
        container.RegisterType(typeof(object), typeof(T),Replace(typeof(T).FullName));
    }

    public static string Replace(string url)
    {
        return WebUtility.UrlEncode(url);
    }
}

And you also have to urlencode when you navigate.

public void Navigate(object navigatePath, string region = RegionNames.ContentRegion,
                         NavigationParameters parameters = null,
                         Action<NavigationResult> navigationCallback = null)
    {
        if (navigatePath == null) return;

        var path = UnityExtensions.Replace(navigatePath.ToString());

        if (parameters == null)
            _regionManager.RequestNavigate(region, path);
        else
        {
            var uri = new Uri(path, UriKind.RelativeOrAbsolute);
            if (navigationCallback == null)
                _regionManager.RequestNavigate(region, uri, parameters);
            else
                _regionManager.RequestNavigate(region, uri, navigationCallback, parameters);
        }
    }

That's it