我正在使用Xamarin工作室,当我点击图片按钮点击时我的应用程序崩溃了。下面是我的代码,当我点击图片按钮时,我的应用程序崩溃了。
using System;
using MvvmCross.Binding.BindingContext;
using MvvmCross.Binding.iOS.Views;
using MvvmCross.iOS.Support.SidePanels;
using MvvmCross.Platform;
using UIKit;
using ViewModelShared;
namespace SelfcareApp.Touch
{
[MvxPanelPresentation(MvxPanelEnum.None, MvxPanelHintType.ActivePanel, true, MvxSplitViewBehaviour.Detail)]
public partial class CcFnfView : BaseViewController<CcFnfViewViewModel>
{
private CcFnfViewViewModel PageViewModel
{
get { return (CcFnfViewViewModel)base.ViewModel; }
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
// PageViewModel.ShowMenu();
var cellWidth = (UIScreen.MainScreen.Bounds.Width - 4 - 8) / 2;
var cellheight = (UIScreen.MainScreen.Bounds.Height - 130) / 2;
var headerView = new MobileNumberHeaderView(new CoreGraphics.CGRect(0, 0, UIScreen.MainScreen.Bounds.Width, 50));
AccountCollectionView.BackgroundColor = UIColor.Clear;
AccountCollectionView.CollectionViewLayout = new UICollectionViewFlowLayout() { ItemSize = new CoreGraphics.CGSize(cellWidth, cellheight), MinimumLineSpacing = 4, MinimumInteritemSpacing = 4 };
AccountCollectionView.RegisterNibForCell(TileViewCell.Nib, TileViewCell.Key);
var homeSource = new MvxCollectionViewSource(AccountCollectionView, TileViewCell.Key);
AccountCollectionView.Source = homeSource;
//AudioAlbumsCollectionView.
var set = this.CreateBindingSet<CcFnfView, CcFnfViewViewModel>();
set.Bind(headerView.LabelFiled).To(vm => vm.DefaultPhone).WithConversion("MSISDN");;
set.Bind(headerView.Button).To(vm => vm.SelectAccountCommand);
set.Bind(headerView.Button).For(x => x.Hidden).To(vm => vm.IsChangeNumberButtonVisible).WithConversion("BooleanReverse");
set.Bind(Title).To(vm => vm.PageTitle);
set.Bind(homeSource).To(vm => vm.MenuItems);
set.Bind(homeSource).For(t => t.SelectionChangedCommand).To(vm => vm.MenuSelectedCommand);
set.Bind(this).For(t => t.Title).To(vm => vm.PageTitle);
set.Bind(Progress).For(t => t.Visible).To(vm => vm.ProgressBarVisibility);
set.Apply();
Add(headerView);
}
public override void ViewWillAppear(bool animated)
{
base.ViewWillAppear(animated);
if (NavigationController != null)
NavigationController.NavigationBarHidden = false;
var sideMenu = Mvx.Resolve<IMvxSideMenu>();
sideMenu.Close();
}
}
}
Designer.cs:
using Foundation;
using System;
using System.CodeDom.Compiler;
using UIKit;
namespace SelfcareApp.Touch
{
[Register ("CcFnfView")]
partial class CcFnfView
{
[Outlet]
UIKit.UICollectionView AccountCollectionView { get; set; }
void ReleaseDesignerOutlets ()
{
if (AccountCollectionView != null) {
AccountCollectionView.Dispose ();
AccountCollectionView = null;
}
}
}
}
应用程序在该行崩溃:
AccountCollectionView.BackgroundColor = UIColor.Clear;