2
有沒有關於如何使用Xavrin的FlyoutNavigation組件使用MvvmCross的示例。MvvmCross:如何在MvvmCross中使用FlyoutNavigation組件
當我嘗試使用MainNavigationViewModel的菜單視圖設置ViewControllers時,出現錯誤。這是我得到的錯誤「System.Reflection.TargetInvocationException:異常已被調用的目標拋出。」
這裏是我的示例代碼:
public class MainNavigationViewModel : MvxViewModel
{
public MainNavigationViewModel()
{
MenuOne = new MenuOneViewModel();
}
private MenuOne _MenuOne;
public MenuOneViewModel MenuOne
{
get { return _MenuOne; }
set
{
_MenuOne = value;
RaisePropertyChanged(() => MenuOne);
}
}
}
[Register("MainNavigationView")]
public sealed class MainNavigationView : MvxViewController
{
protected MainNavigationViewModel MainNavViewModel
{ get { return base.ViewModel as MainNavigationViewModel; } }
public MainNavigationView()
{
ViewDidLoad();
}
public override void ViewWillAppear(bool animated)
{
base.ViewWillAppear(animated);
NavigationController.NavigationBarHidden = true;
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
if (ViewModel == null)
return;
var flyoutNavigationController = new FlyoutNavigationController();
var menuViewRoot = new RootElement(null);
var menuItems = new List<StringElement>()
{
new StringElement("Menu One")
};
var menuSection = new Section("Main Menu") { menuItems };
menuViewRoot.Add(menuSection);
flyoutNavigationController.NavigationRoot = menuViewRoot;
var viewControllers = new UIViewController[1];
viewControllers[0] = CreateMenuItemController(MainNavViewModel.MainOne);
flyoutNavigationController.ViewControllers = viewControllers;
flyoutNavigationController.View.Frame = UIScreen.MainScreen.Bounds;
flyoutNavigationController.ToggleMenu();
Add(flyoutNavigationController.View);
}
private UIViewController CreateMenuItemController(IMvxViewModel viewModel)
{
var controller = new UINavigationController();
var screen = this.CreateViewControllerFor(viewModel) as UIViewController;
controller.PushViewController(screen, false);
return controller;
}
}
嘿的一個分支 - 這可能與對話使用它?我看到代碼使用了一個MvxTouchViewPresenter - 我對此不熟悉 - 今天將會看到它 - 想知道如果您至少可以通過發信號告訴我一個開頭的東西嗎? – iwayneo