コード例 #1
0
        public override void OnViewModelAndViewLoadedOverride()
        {
            base.OnViewModelAndViewLoadedOverride();

            var scheduleView = new UIScheduleView(ViewModel)
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            ContentView.Add(scheduleView);
            scheduleView.StretchWidthAndHeight(ContentView);

            var toolbar = new UIToolbar()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            ContentView.Add(toolbar);
            toolbar.StretchWidth(ContentView);
            toolbar.SetHeight(44);
            _labelDateRange = new UILabel()
            {
                BackgroundColor = UIColor.Clear,
                Font            = UIFont.PreferredCallout
            };
            _labelYearAndWeekContainer = new UIView();
            _labelYearAndWeek          = new UILabel()
            {
                Font            = UIFont.PreferredCaption1,
                TextColor       = UIColor.Gray,
                BackgroundColor = UIColor.Clear
            };
            _labelYearAndWeekContainer.Add(_labelYearAndWeek);
            BindingHost.SetBindings(new string[]
            {
                nameof(ViewModel.DisplayStartDate),
                nameof(ViewModel.DisplayEndDate),
                nameof(ViewModel.CurrentWeek),
                nameof(ViewModel.HasTwoWeekSchedule)
            }, UpdateToolbarLabels);
            toolbar.Items = new UIBarButtonItem[]
            {
                new UIBarButtonItem(_labelDateRange),
                new UIBarButtonItem(UIBarButtonSystemItem.FixedSpace)
                {
                    Width = 6
                },
                new UIBarButtonItem(_labelYearAndWeekContainer),
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                new UIBarButtonItem(UIImage.FromBundle("ToolbarBack"), UIBarButtonItemStyle.Plain, new WeakEventHandler(delegate { ViewModel.PreviousWeek(); }).Handler),
                new UIBarButtonItem(UIBarButtonSystemItem.FixedSpace)
                {
                    Width = 20
                },
                new UIBarButtonItem(UIImage.FromBundle("ToolbarForward"), UIBarButtonItemStyle.Plain, new WeakEventHandler(delegate { ViewModel.NextWeek(); }).Handler)
            };
            MainScreenViewController.ListenToTabBarHeightChanged(ref _tabBarHeightListener, delegate
            {
                toolbar.RemovePinToBottom(ContentView).PinToBottom(ContentView, (int)MainScreenViewController.TAB_BAR_HEIGHT);
            });

            ViewModel.PropertyChanged += new WeakEventHandler <PropertyChangedEventArgs>(ViewModel_PropertyChanged).Handler;
            UpdateLayoutMode();
        }