Archived
WIP: more pages + reflection fix for navigation
This commit is contained in:
1 parent
8d69e7ffab
commit
1c14530139
15 files changed
+249
-57
No files matched your search
@@ -6,13 +6,43 @@ namespace MobileApp1.Views
|
||||
public class ContentPageHelper
|
||||
{
|
||||
|
||||
public static App GetApp(ContentPage view) => GetParentElement<App>(view);
|
||||
public static App GetApp(ContentPage view) => (App)GetParentElement<App>(view);
|
||||
//{
|
||||
// if (view == null) return null;
|
||||
|
||||
public static Application GetApplication(ContentPage view) => GetParentElement<Application>(view);
|
||||
// Element item = view.Parent;
|
||||
|
||||
public static MainPage GetMainPage(ContentPage view) => GetParentElement<MainPage>(view);
|
||||
// while (true)
|
||||
// {
|
||||
// if (item == null) break;
|
||||
// if (item is App) break;
|
||||
|
||||
public static T GetParentElement<T>(ContentPage view)
|
||||
// item = item.Parent;
|
||||
// }
|
||||
|
||||
// return (item as App);
|
||||
//}
|
||||
|
||||
public static Application GetApplication(ContentPage view) => (Application)GetParentElement<Application>(view);
|
||||
//{
|
||||
// if (view == null) return null;
|
||||
|
||||
// Element item = view.Parent;
|
||||
|
||||
// while (true)
|
||||
// {
|
||||
// if (item == null) break;
|
||||
// if (item is Application) break;
|
||||
|
||||
// item = item.Parent;
|
||||
// }
|
||||
|
||||
// return (item as Application);
|
||||
// }
|
||||
|
||||
public static MainPage GetMainPage(ContentPage view) => (MainPage)GetParentElement<MainPage>(view);
|
||||
|
||||
public static object GetParentElement<T>(ContentPage view)
|
||||
{
|
||||
if (view == null) return default(T);
|
||||
|
||||
@@ -26,14 +56,16 @@ namespace MobileApp1.Views
|
||||
item = item.Parent;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return (T)Convert.ChangeType(item, typeof(T));
|
||||
}
|
||||
catch (InvalidCastException)
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
//try
|
||||
//{
|
||||
// return (T)Convert.ChangeType(item, typeof(T));
|
||||
//}
|
||||
//catch (InvalidCastException)
|
||||
//{
|
||||
// return default(T);
|
||||
//}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public static void SetDetailPage(ContentPage view, Type pageType, bool useNavigationPage = true) => SetDetailPage(view, (Page)Activator.CreateInstance(pageType), useNavigationPage);
|
||||
|
||||
@@ -6,13 +6,43 @@ namespace MobileApp1.Views
|
||||
public class ContentViewHelper
|
||||
{
|
||||
|
||||
public static App GetApp(ContentView view) => GetParentElement<App>(view);
|
||||
public static App GetApp(ContentView view) => (App)GetParentElement<App>(view);
|
||||
//{
|
||||
// if (view == null) return null;
|
||||
|
||||
public static Application GetApplication(ContentView view) => GetParentElement<Application>(view);
|
||||
// Element item = view.Parent;
|
||||
|
||||
public static ContentPage GetContentPage(ContentView view) => GetParentElement<ContentPage>(view);
|
||||
// while (true)
|
||||
// {
|
||||
// if (item == null) break;
|
||||
// if (item is App) break;
|
||||
|
||||
public static T GetParentElement<T>(ContentView view)
|
||||
// item = item.Parent;
|
||||
// }
|
||||
|
||||
// return (item as App);
|
||||
//}
|
||||
|
||||
public static Application GetApplication(ContentView view) => (Application)GetParentElement<Application>(view);
|
||||
//{
|
||||
// if (view == null) return null;
|
||||
|
||||
// Element item = view.Parent;
|
||||
|
||||
// while (true)
|
||||
// {
|
||||
// if (item == null) break;
|
||||
// if (item is Application) break;
|
||||
|
||||
// item = item.Parent;
|
||||
// }
|
||||
|
||||
// return (item as Application);
|
||||
//}
|
||||
|
||||
public static ContentPage GetContentPage(ContentView view) => (ContentPage)GetParentElement<ContentPage>(view);
|
||||
|
||||
public static object GetParentElement<T>(ContentView view)
|
||||
{
|
||||
if (view == null) return default(T);
|
||||
|
||||
@@ -26,14 +56,16 @@ namespace MobileApp1.Views
|
||||
item = item.Parent;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return (T)Convert.ChangeType(item, typeof(T));
|
||||
}
|
||||
catch (InvalidCastException)
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
//try
|
||||
//{
|
||||
// return (T)Convert.ChangeType(item, typeof(T));
|
||||
//}
|
||||
//catch (InvalidCastException)
|
||||
//{
|
||||
// return default(T);
|
||||
//}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public static void SetMainPage(ContentView view, Page page)
|
||||
|
||||
Reference in new issue
Block a user