public App() { Picker pickerArrival = new Picker (); pickerArrival.Items.Add ("Android"); pickerArrival.Items.Add ("iOS"); pickerArrival.Items.Add ("Windows Phone"); Button bt = new Button { Text = "Select OS", }; bt.Clicked += (e, sender) => { Console.WriteLine ("Selected item: " + pickerArrival.Items [pickerArrival.SelectedIndex] + " - index: " + pickerArrival.SelectedIndex); }; // The root page of your application MainPage = new ContentPage { Content = new StackLayout { VerticalOptions = LayoutOptions.Center, Children = { pickerArrival, bt } } }; }
ContentPage CreatePage (Color backgroundColor) { _index++; var button = new Button () { Text = "next Page", }; button.Clicked += (sender, e) => { var page = CreatePage (Color.Green); _navigationPage.PushAsync (page); }; var contentPage = new ContentPage () { Content = new StackLayout () { BackgroundColor = backgroundColor, VerticalOptions = LayoutOptions.Fill, Children = { new Label () { Text = "page " + _index, }, } } }; return contentPage; }
public MyControls () { Title = "My First Xamarin.Forms"; var label = new Label { Text = "Custom label", Font = Font.SystemFontOfSize (20), TextColor = Color.Aqua, BackgroundColor = Color.Gray, IsVisible = true, LineBreakMode = LineBreakMode.WordWrap }; var button = new Button { Text = "Click Me!" }; int i = 1; button.Clicked += (s, e) => button.Text = "You clicked me: " + i++; button.Clicked += (s, e) => Navigation.PushAsync(new MySecondPage()); Content = new StackLayout { Spacing = 10, VerticalOptions = LayoutOptions.Center, Children = { label, button } }; }
public ScriptInputGroupPage(InputGroup inputGroup, List<InputGroup> previousInputGroups) { Title = "Input Group"; StackLayout contentLayout = new StackLayout { Orientation = StackOrientation.Vertical, VerticalOptions = LayoutOptions.FillAndExpand }; foreach (StackLayout stack in UiProperty.GetPropertyStacks(inputGroup)) contentLayout.Children.Add(stack); Button editInputsButton = new Button { Text = "Edit Inputs", FontSize = 20, HorizontalOptions = LayoutOptions.FillAndExpand }; editInputsButton.Clicked += async (o, e) => { await Navigation.PushAsync(new ScriptInputsPage(inputGroup, previousInputGroups)); }; contentLayout.Children.Add(editInputsButton); Content = new ScrollView { Content = contentLayout }; }
public HomePageCS () { var rotateButton = new Button { Text = "Rotate Animation" }; rotateButton.Clicked += OnRotateAnimationButtonClicked; var relativeRotateButton = new Button { Text = "Relative Rotate Animation" }; relativeRotateButton.Clicked += OnRelativeRotateAnimationButtonClicked; var rotateAnchorButton = new Button { Text = "Rotate Animation with Anchors" }; rotateAnchorButton.Clicked += OnRotateAnimationWithAnchorsButtonClicked; var multipleRotateButton = new Button { Text = "Multiple Rotations" }; multipleRotateButton.Clicked += OnMultipleRotationAnimationButtonClicked; var scaleButton = new Button { Text = "Scale Animation" }; scaleButton.Clicked += OnScaleAnimationButtonClicked; var relativeScaleButton = new Button { Text = "Relative Scale Animation" }; relativeScaleButton.Clicked += OnRelativeScaleAnimationButtonClicked; var transformButton = new Button { Text = "Transform Animation" }; transformButton.Clicked += OnTransformAnimationButtonClicked; var fadeButton = new Button { Text = "Fade Animation" }; fadeButton.Clicked += OnFadeAnimationButtonClicked; Title = "Basic Animation Demo"; Content = new StackLayout { Margin = new Thickness (0, 20, 0, 0), Children = { rotateButton, relativeRotateButton, rotateAnchorButton, multipleRotateButton, scaleButton, relativeScaleButton, transformButton, fadeButton } }; }
public ProductImagePage(ImageSource productImageSource) { Padding = Device.OnPlatform(new Thickness(0, 20, 0, 0), new Thickness(0), new Thickness(0)); _productImageSource = productImageSource; BackgroundColor = Color.FromRgba(0, 0, 0, 127); var absoluteLayout = new AbsoluteLayout { VerticalOptions = LayoutOptions.FillAndExpand }; var closeButtom = new Button { WidthRequest = 50, Image = "backspace.png", BackgroundColor = Color.Transparent }; closeButtom.Clicked += OnCloseButtonClicked; var image = new Image { Source = _productImageSource }; AbsoluteLayout.SetLayoutFlags(closeButtom, AbsoluteLayoutFlags.PositionProportional); AbsoluteLayout.SetLayoutBounds(closeButtom, new Rectangle(1f, 0f, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize)); AbsoluteLayout.SetLayoutFlags(image, AbsoluteLayoutFlags.PositionProportional); AbsoluteLayout.SetLayoutBounds(image, new Rectangle(0.5f, 0.5f, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize)); absoluteLayout.Children.Add(image); absoluteLayout.Children.Add(closeButtom); Content = absoluteLayout; }
public RequiredFieldTriggerPage () { var l = new Label { Text = "Entry requires length>0 before button is enabled", }; l.FontSize = Device.GetNamedSize (NamedSize.Small, l); var e = new Entry { Placeholder = "enter name" }; var b = new Button { Text = "Save", HorizontalOptions = LayoutOptions.Center }; b.FontSize = Device.GetNamedSize (NamedSize.Large ,b); var dt = new DataTrigger (typeof(Button)); dt.Binding = new Binding ("Text.Length", BindingMode.Default, source: e); dt.Value = 0; dt.Setters.Add (new Setter { Property = Button.IsEnabledProperty, Value = false }); b.Triggers.Add (dt); Content = new StackLayout { Padding = new Thickness(0,20,0,0), Children = { l, e, b } }; }
public Pagina1() { Label texto = new Label { Text = "Página 1", TextColor = Color.Blue }; Button boton = new Button { Text = "Click para navegar a la página DOS" }; boton.Clicked += (sender, e) => { this.Navigation.PushAsync(new Pagina2()); }; //Stacklayout permite apilar los controles verticalmente StackLayout stackLayout = new StackLayout { Children = { texto, boton } }; //Como esta clase hereda de ContentPage, podemos usar estas propiedades directamente this.Content = stackLayout; this.Padding = new Thickness (5, Device.OnPlatform (20, 5, 5), 5, 5); }
public App() { var btnCs = new Button() { Text = "Abas Code Only" }; btnCs.Clicked += btnCs_Clicked; var btnXaml = new Button() { Text = "Abas XAML" }; btnXaml.Clicked += btnXaml_Clicked; // The root page of your application MainPage = new NavigationPage(new ContentPage { Content = new StackLayout { VerticalOptions = LayoutOptions.Center, Children = { new Label { XAlign = TextAlignment.Center, Text = "Abra uma das Telas" }, btnCs, btnXaml } } }); }
public InitialPage() { BindingContext = new InitialPageModel (this.Navigation); Title = "Welcome to Peter"; Label timeLabel = new Label { HorizontalOptions = LayoutOptions.Center, }; timeLabel.SetBinding<InitialPageModel> (Label.TextProperty, vm => vm.DrinkingHoursDisplay); Slider timeSlider = new Slider (1, 24, 5) { HorizontalOptions = LayoutOptions.FillAndExpand, }; timeSlider.SetBinding<InitialPageModel> (Slider.ValueProperty, vm => vm.DrinkingHours, BindingMode.TwoWay); Button pressMe = new Button { Text = "Help Peter", HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand, FontSize = 60, HeightRequest = 200, BackgroundColor = Color.Yellow, }; pressMe.SetBinding<InitialPageModel> (Button.CommandProperty, vm => vm.PressMeCommand); Content = new StackLayout { Children = { timeLabel, timeSlider, pressMe, } }; }
public MultipleChoiceQuestion () { Title = "Multiple Choice"; Label q1 = new Label{ Text = "Identify the visual field defect below." }; var answers = new String[]{"Choose an option", "Bitemporal hemianopia", "Binasal hemianopia", "Central scotoma", "Right homonymous hemianopia", "Temporal homonymous hemianopia"}; Picker q1a = new Picker (); foreach (var a in answers) { q1a.Items.Add (a); } var button = new Button {Text="Submit"}; button.Clicked += (object sender, EventArgs e) => { if(q1a.SelectedIndex == 1){ DisplayAlert("Correct!", "Well done, that's the right answer", "OK"); }else{ DisplayAlert("Incorrect", String.Format("The correct answer is {0}", answers[1]), "OK"); } }; Content = new StackLayout { Children = { q1, new Image{ Source = ImageSource.FromUri(new Uri("http://i.imgur.com/q7l03ZG.png")) }, q1a, button } }; }
public Page2() { var label = new Label { Text = "Hello ContentPage 2" }; Device.OnPlatform( iOS: () => { var parentTabbedPage = this.ParentTabbedPage() as MainTabbedPage; if (parentTabbedPage != null) { // HACK: get content out from under status bar if a navigation bar isn't doing that for us already. Padding = new Thickness(Padding.Left, Padding.Top + 25f, Padding.Right, Padding.Bottom); } } ); var button = new Button() { Text = "Switch to Tab 1; add a Page 2 there", }; button.Clicked += async (sender, e) => { var tabbedPage = this.ParentTabbedPage() as MainTabbedPage; var partPage = new Page2() { Title = "Added page 2" }; await tabbedPage.SwitchToTab1(partPage, resetToRootFirst: false); }; Content = new StackLayout { Children = { button, label, } }; }
public ContentDemo() { Button button = new Button { Text = "Edit Profile", HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.CenterAndExpand }; button.Clicked += OnButtonClicked; Image myImage = new Image { Aspect = Aspect.Fill, Source = ImageSource.FromUri( new Uri(@"https://4e72eb44013d543eb0c67f8fbddf2ed30743ec8d.googledrive.com/host/0B70CO9lnNPfceHNFLXh2Wm8yMHc/List-Most-Expensive-Cars-photo-OdYL.jpg")) }; this.Title = "Content Page"; RelativeLayout relativeLayout = new RelativeLayout (); relativeLayout.Children.Add (myImage, Constraint.Constant (0), Constraint.Constant (0), Constraint.RelativeToParent ((parent) => { return parent.Width; }), Constraint.RelativeToParent ((parent) => { return parent.Height; })); relativeLayout.Children.Add (button, Constraint.RelativeToParent ((parent) => {return parent.Width/2;} ), Constraint.RelativeToParent ((parent) => {return parent.Height/2;} ), Constraint.RelativeToParent ((parent) => { return 75.0; }), Constraint.RelativeToParent ((parent) => { return 75.0; })); Content = relativeLayout; }
public MyPage() { Button buttonToUpdate = new Button {Text = "Image Button", Image = "icon.png"}; Button UpdatesList = new Button {Text="Add Item to list"}; buttonToUpdate.SetBinding (Button.ImageProperty, new Binding("ImagePath")); UpdatesList.Clicked += (sender,e) => { listToWatch.Add (DateTime.Now.ToString()); }; listToWatch.CollectionChanged+=(sender,e)=>{ if( listToWatch.Count%2==1) { ImagePath="noci.png"; } else { ImagePath="icon.png"; } }; Content = new StackLayout { Children = { buttonToUpdate, UpdatesList } }; Content.BindingContext = this; }
public TableView(MatrixMainPageView mainView) { InitializeComponent(); _mainView = mainView; Title = "Таблица"; if (Device.OS == TargetPlatform.iOS) { Icon = "tableTabIcon.png"; { var btn = new Button() { Text = "Фильтры" }; btn.Clicked += (s, e) => { mainView.IsPresented = !mainView.IsPresented; }; Grid.SetRow(btn,1); cnvRoot.Children.Add(btn); } } cnvRoot.Padding = Device.OnPlatform(10, 8, 10); ThemeManager.ThemeName = Themes.Light; dataGrid.RightSwipeButtons.Add(new SwipeButtonInfo() { BackgroundColor = Color.Yellow, TextColor = Color.Black, AutoCloseOnTap = true, Caption = "График" }); dataGrid.SwipeButtonClick += DataGrid_SwipeButtonClick; }
public FilterPage () { this.Icon = "slideout.png"; this.Title = "Filter"; _scope = App.AutoFacContainer.BeginLifetimeScope(); var vm = _scope.Resolve<FilterViewModel> (); BindingContext = vm; var layout = new StackLayout (); layout.Children.Add (new Label() {Text = "Enter a filter"}); layout.Children.Add (new Label() {Text = "Subject"}); var subjectEntry = new Entry(); subjectEntry.SetBinding (Entry.TextProperty, "Subject"); layout.Children.Add (subjectEntry); var button = new Button () { Text = "Apply Filter" }; button.SetBinding (Button.CommandProperty, "FilterMeasures"); layout.Children.Add (button); Content = layout; }
public NetworkStatusPage() { var networkLabel = new Label { Text = "Network Status", YAlign = TextAlignment.Center }; var networkBox = new BoxView { Color = Color.White, HeightRequest = 25, WidthRequest = 25 }; var networkStack = new StackLayout { Orientation = StackOrientation.Horizontal, Padding = 15, Spacing = 25, Children = { networkLabel, networkBox } }; var button = new Button { Text = "Update Status", HorizontalOptions = LayoutOptions.FillAndExpand }; button.Clicked += (sender, e) => { var service = DependencyService.Get<INetworkService>(); var isConnected = service.IsConnected(); networkBox.Color = isConnected ? Color.Green : Color.Red; }; Content = new StackLayout { Children = { networkStack, button } }; }
public GlobalPage1() { Title = "First Global Page"; Label homeLabel = new Label { Text = "Assigning id = 12345", FontSize = 40 }; firstButton = new Button { Text = "Go to Second Page" }; firstButton.Clicked += async (sendernav, args) => await Navigation.PushAsync(new GlobalPage2()); var stackLayout = new StackLayout { Children = { homeLabel, firstButton } }; this.Content = stackLayout; Global.Instance.myData = "12345"; }
public SimplestKeypad() { // Create a Vertical stack for the entire keypad. var mainStack = new StackLayout { VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center }; // First row is the Label. displayLabel = new Label { FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)), VerticalOptions = LayoutOptions.Center, XAlign = TextAlignment.End }; mainStack.Children.Add(displayLabel); //Second row is the backspace Button. backspaceButton = new Button { Text = "\u21E6", FontSize = Device.GetNamedSize(NamedSize.Large, typeof (Button)), IsEnabled = false }; backspaceButton.Clicked += OnBackSpaceButtonClicked; mainStack.Children.Add(backspaceButton); // Now do the 10 number keys. StackLayout rowStack = null; for (var num = 1; num <= 10; num++) { if ((num - 1)%3 == 0) { rowStack = new StackLayout { Orientation = StackOrientation.Horizontal }; mainStack.Children.Add(rowStack); } var digitButton = new Button { Text = (num % 10).ToString(), FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Button)), StyleId = (num % 10).ToString() }; digitButton.Clicked += OnDigitButtonClicked; //For the zero button, expand to fill horizontally. if (num == 10) { digitButton.HorizontalOptions = LayoutOptions.FillAndExpand; } rowStack.Children.Add(digitButton); } this.Content = mainStack; }
public LoginPage(ILoginManager ilm) { var button = new Button { Text = "Login" }; button.Clicked += (sender, e) => { if (String.IsNullOrEmpty(username.Text) || String.IsNullOrEmpty(password.Text)) { DisplayAlert("Validation Error", "Username and Password are required", "Re-try"); } else { // REMEMBER LOGIN STATUS! App.Current.Properties["IsLoggedIn"] = true; ilm.ShowMainPage(); } }; username = new Entry { Text = "" }; password = new Entry { Text = "" }; Content = new StackLayout { Padding = new Thickness (10, 40, 10, 10), Children = { new Label { Text = "Login", FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)) }, new Label { Text = "Username" }, username, new Label { Text = "Password" }, password, button } }; }
private void InitializeComponent() { this.LoadFromXaml(typeof(InicioPage)); btnLogin = this.FindByName<Button>("btnLogin"); btnRegistrar = this.FindByName<Button>("btnRegistrar"); btnSobre = this.FindByName<Button>("btnSobre"); }
public StartStopLayout () { btnStart = new Button { Text = "Start", Font = Font.SystemFontOfSize (NamedSize.Large), TextColor = Color.Black, BackgroundColor = Color.Green, BorderRadius = 10, HorizontalOptions = LayoutOptions.FillAndExpand }; btnStop = new Button { Text = "Break", Font = Font.SystemFontOfSize (NamedSize.Large), TextColor = Color.Black, BorderRadius = 10, HorizontalOptions = LayoutOptions.FillAndExpand }; var activeEntry = TimeManager.GetActiveTimeEntry(); if (activeEntry != null) { btnStop.IsEnabled = true; btnStop.BackgroundColor = Color.Red; } else { btnStop.IsEnabled = false; btnStop.BackgroundColor = Color.Gray; } this.HorizontalOptions = LayoutOptions.FillAndExpand; this.Orientation = StackOrientation.Horizontal; this.Children.Add (btnStart); this.Children.Add (btnStop); }
public ChatList () { Button openMessenger = new Button () { Text = "Open Chat" }; Button openScalableEntry = new Button () { Text = "Open ScalabaleEntry" }; Title = "Chat Rooms"; openMessenger.Clicked += (object sender, EventArgs e) => {Navigation.PushAsync(new ChatPage()); }; openScalableEntry.Clicked += (object sender, EventArgs e) => {Navigation.PushAsync(new customInputForm()); }; Content = new StackLayout { Children = { new Label { Text = "All of the different chat rooms will be listed here, this is the root navigation page" }, openMessenger, openScalableEntry } }; }
public LoginPageCS () { var toolbarItem = new ToolbarItem { Text = "Sign Up" }; toolbarItem.Clicked += OnSignUpButtonClicked; ToolbarItems.Add (toolbarItem); messageLabel = new Label (); usernameEntry = new Entry { Placeholder = "username" }; passwordEntry = new Entry { IsPassword = true }; var loginButton = new Button { Text = "Login" }; loginButton.Clicked += OnLoginButtonClicked; Title = "Login"; Content = new StackLayout { VerticalOptions = LayoutOptions.StartAndExpand, Children = { new Label { Text = "Username" }, usernameEntry, new Label { Text = "Password" }, passwordEntry, loginButton, messageLabel } }; }
public Login() { Entry usuario = new Entry { Placeholder = "Usuario" }; Entry clave = new Entry { Placeholder = "Clave", IsPassword = true }; Button boton = new Button { Text = "Login", TextColor = Color.White, BackgroundColor = Color.FromHex ("77D065") }; boton.Clicked += (sender, e) => { }; //Stacklayout permite apilar los controles verticalmente StackLayout stackLayout = new StackLayout { Spacing = 20, Padding = 50, VerticalOptions = LayoutOptions.Center, Children = { usuario, clave, boton } }; //Como esta clase hereda de ContentPage, podemos usar estas propiedades directamente this.Content = stackLayout; this.Padding = new Thickness (5, Device.OnPlatform (20, 5, 5), 5, 5); }
public ExtendedScrollView () { InitializeComponent (); var container = new StackLayout () { HorizontalOptions= LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand }; var buttonToScroll = new Button () { Text = "Scroll to end" }; container.Children.Add (buttonToScroll); for (int i = 0; i < 10; i++) { container.Children.Add (new Image { Aspect = Aspect.AspectFill, Source = ImageSource.FromUri (new Uri("http://www.stockvault.net/data/2011/05/31/124348/small.jpg")), HeightRequest = _imageHeight }); } var sv = new Xamarin.Forms.Labs.Controls.ExtendedScrollView { Content = container, HorizontalOptions= LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand}; sv.Scrolled+= async (ScrollView arg1, Rectangle arg2) => { if(arg2.Y > sv.Bounds.Height && !_displayAlert) { _displayAlert = true; await DisplayAlert("Scroll event", "User scrolled pass bounds","Ok","cancel"); } }; buttonToScroll.Clicked+= (object sender, EventArgs e) => { sv.Position = new Point(sv.Position.X, sv.ContentSize.Height-_imageHeight); }; Content = sv; }
public MenuPage () { Title = "LoginPattern"; Icon = "slideout.png"; var section = new TableSection () { new TextCell {Text = "Sessions"}, new TextCell {Text = "Speakers"}, new TextCell {Text = "Favorites"}, new TextCell {Text = "Room Plan"}, new TextCell {Text = "Map"}, }; var root = new TableRoot () {section} ; tableView = new TableView () { Root = root, Intent = TableIntent.Menu, }; var logoutButton = new Button { Text = "Logout" }; logoutButton.Clicked += (sender, e) => { App.Current.Logout(); }; Content = new StackLayout { BackgroundColor = Color.Gray, VerticalOptions = LayoutOptions.FillAndExpand, Children = { tableView, logoutButton } }; }
public RelativeLayoutDemoCode () { Title = "Relative Layout Demo - C#"; outerLayout = new AbsoluteLayout (); layout = new RelativeLayout (); centerLabel = new Label { FontSize = 20, Text = "RelativeLayout Demo"}; buttonLayout = new AbsoluteLayout (); box = new BoxView { Color = Color.Blue, HeightRequest = 50, WidthRequest = 50 }; layout.Children.Add (box, Constraint.RelativeToParent ((parent) => { return (parent.Width * .5) - 50; }), Constraint.RelativeToParent ((parent) => { return (parent.Height * .1) - 50; })); layout.Children.Add (centerLabel, Constraint.RelativeToParent ((parent) => { return (parent.Width * .5) - 50; }), Constraint.RelativeToParent ((parent) => { return (parent.Height * .5) - 50; })); moveButton = new Button { BackgroundColor = Color.White, FontSize = 20, TextColor = Color.Lime, Text = "Move", BorderRadius = 0}; buttonLayout.Children.Add (moveButton, new Rectangle(0,1,1,1), AbsoluteLayoutFlags.All); outerLayout.Children.Add (layout, new Rectangle(0,0,1,1), AbsoluteLayoutFlags.All); outerLayout.Children.Add (buttonLayout, new Rectangle(0,1,1,50), AbsoluteLayoutFlags.PositionProportional|AbsoluteLayoutFlags.WidthProportional); moveButton.Clicked += MoveButton_Clicked; x = 0f; y = 0f; Content = outerLayout; }
protected override void OnAppearing() { base.OnAppearing (); var goXamlButton = new Button { Text = " Go With Xaml " , TextColor= Color.Black, BackgroundColor= Color.Gray}; goXamlButton.Clicked += (sender, e) => { Navigation.PushAsync (new MenuPage()); }; var goCodeButton = new Button { Text = " Go With Code Only " , TextColor= Color.Black, BackgroundColor= Color.Gray }; goCodeButton.Clicked += (sender, e) => { Navigation.PushAsync (new TodoListPage()); }; // The root page of your application Content = new StackLayout { VerticalOptions = LayoutOptions.Center, Children = { new Label { XAlign = TextAlignment.Center, Text = "Welcome " + ((UserProfile)BindingContext).Name }, goCodeButton, goXamlButton } }; }
public EsqueciMinhaSenhaPage() { var lblTexto = new Label { Style = Estilos._estiloFonteCategorias, YAlign = TextAlignment.Center, Text = AppResources.TextoEsqueciMinhaSenha }; var entEmail = new Entry { Keyboard = Keyboard.Email }; var btnEnviar = new Button { Text = AppResources.TextoResetarSenha, Style = Estilos._estiloPadraoButton, HorizontalOptions = LayoutOptions.Center }; var mainLayout = new StackLayout { VerticalOptions = LayoutOptions.FillAndExpand, Orientation = StackOrientation.Horizontal, Padding = new Thickness(0, 20, 0, 0), Spacing = 10, Children = { lblTexto, entEmail, btnEnviar } }; this.Content = mainLayout; }