public override void ViewDidLoad() { base.ViewDidLoad(); refreshButton.Clicked += RefreshButton_Clicked; // Set the binding BEFORE adding items so as to avoid restyling everything styleManager = new StyleManager(); bindings.Add(this.SetBinding(() => ViewModelLocator.Styles.CustomTags, () => styleManager.CustomTags)); styleOne = styleManager.Add(titleOne, TextStyles.H2); bindings.Add(this.SetBinding(() => Vm.TitleOne, () => styleOne.Text)); styleTwo = styleManager.Add(titleTwo, TextStyles.H1); bindings.Add(this.SetBinding(() => Vm.TitleTwo, () => styleTwo.Text)); styleThree = styleManager.Add(titleThree, TextStyles.H2); bindings.Add(this.SetBinding(() => Vm.TitleThree, () => styleThree.Text)); styleBody = styleManager.Add(textBody, TextStyles.Body); bindings.Add(this.SetBinding(() => Vm.Body, () => styleBody.Text)); styleEntry = styleManager.Add(textEntry, TextStyles.Body, enableHtmlEditing: true); bindings.Add(this.SetBinding(() => Vm.Entry, () => styleEntry.Text)); Xamarin.IQKeyboardManager.SharedManager.EnableAutoToolbar = true; Xamarin.IQKeyboardManager.SharedManager.ShouldResignOnTouchOutside = true; var touchGesture = new UITapGestureRecognizer(HandleAction); View.AddGestureRecognizer(touchGesture); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Register Fonts TextStyle.Default.AddFont("Archistico-Normal", "Archistico_Simple.ttf"); TextStyle.Default.AddFont("Avenir-Medium", "Avenir-Medium.ttf"); TextStyle.Default.AddFont("Avenir-Book", "Avenir-Book.ttf"); TextStyle.Default.AddFont("Avenir-Heavy", "Avenir-Heavy.ttf"); TextStyle.Default.AddFont("BreeSerif-Regular", "BreeSerif-Regular.ttf"); TextStyle.Default.AddFont("OpenSans-CondensedBold", "OpenSans-CondBold.ttf"); TextStyle.Default.AddFont("OpenSans-CondensedLight", "OpenSans-CondLight.ttf"); SimpleIoc.Default.Register <ITextStyle>(() => TextStyle.Default); AppBootstrapper.Init(); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); toolbar.Title = "Native Text Demo"; SetActionBar(toolbar); // Set the binding BEFORE adding items so as to avoid restyling everything styleManager = new StyleManager(); bindings.Add(this.SetBinding(() => ViewModelLocator.Styles.CustomTags, () => styleManager.CustomTags)); // Assign and bind the views styleOne = styleManager.Add(FindViewById <TextView>(Resource.Id.titleOne), TextStyles.H2); bindings.Add(this.SetBinding(() => Vm.TitleOne, () => styleOne.Text)); styleTwo = styleManager.Add(FindViewById <TextView>(Resource.Id.titleTwo), TextStyles.H1); bindings.Add(this.SetBinding(() => Vm.TitleTwo, () => styleTwo.Text)); styleThree = styleManager.Add(FindViewById <TextView>(Resource.Id.titleThree), TextStyles.H2); bindings.Add(this.SetBinding(() => Vm.TitleThree, () => styleThree.Text)); styleBody = styleManager.Add(FindViewById <TextView>(Resource.Id.textBody), TextStyles.Body); bindings.Add(this.SetBinding(() => Vm.Body, () => styleBody.Text)); editText = FindViewById <EditText>(Resource.Id.textEdit); styleEntry = styleManager.Add(editText, TextStyles.Body, enableHtmlEditing: true); bindings.Add(this.SetBinding(() => Vm.Entry, () => styleEntry.Text)); // Dismiss keyboard on tap of background editText.EditorAction += (sender, e) => { if (e.ActionId == ImeAction.Done) { DismissKeyboard(); } }; var layout = (LinearLayout)FindViewById(Resource.Id.layout); layout.Touch += (sender, e) => DismissKeyboard(); }