我有ÆØÅ的名字。如果我尝试导航到其中一个,我得到system.object而不是我的视图。
unity.RegisterTypeForNavigation();
public static void RegisterTypeForNavigation<T>(this IUnityContainer container)
{
container.RegisterType(typeof(object), typeof(T), typeof(T).FullName);
}
我应该逃避FullName吗?
答案 0 :(得分:0)
是的,你应该url编码类型名称,fx。像这样
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);
}
}
导航时还需要urlencode。
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);
}
}
那是