public DatePickerDemoPage() { Label header = new Label { Text = "DatePicker", Font = Font.BoldSystemFontOfSize(50), HorizontalOptions = LayoutOptions.Center }; DatePicker datePicker = new DatePicker { Format = "D", VerticalOptions = LayoutOptions.CenterAndExpand }; // Accomodate iPhone status bar. this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5); // Build the page. this.Content = new StackLayout { Children = { header, datePicker } }; }
void CreateControls() { _picker = new DatePicker { Format = "D" }; _manExpense = new Entry { Placeholder = "Exemple : 0,00", Keyboard = Keyboard.Numeric }; _manExpense.TextChanged += numberEntry_TextChanged; _womanExpense = new Entry { Placeholder = "Exemple : 0,00", Keyboard = Keyboard.Numeric }; _womanExpense.TextChanged += numberEntry_TextChanged; _details = new Editor { BackgroundColor = AppColors.Gray.MultiplyAlpha(0.15d), HeightRequest = 150 }; Content = new StackLayout { Padding = new Thickness(20), Spacing = 10, Children = { new Label { Text = "Date" }, _picker, new Label { Text = "Man expense" }, _manExpense, new Label { Text = "Woman expense" }, _womanExpense, new Label { Text = "Informations" }, _details } }; }
public MainPage() { Label theLabel = new Label() { Text = " click ", HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand }; Button theButton = new Button() { Text = "Click Me", HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand }; theButton.Clicked +=(sender, e) => { theLabel.Text = string.Format("{0} {1}"," click ",theLabel.Text); }; DatePicker dtPicket = new DatePicker(); var container = new StackLayout() { Padding = new Thickness(20, Device.OnPlatform(20,0,0),20,20) }; container.Children.Add(dtPicket); container.Children.Add(theButton); container.Children.Add(theLabel); Content = new ScrollView() { Content = container }; }
public SaveToDictionaryCS() { var labelStyle = new Style(typeof(Label)) { Setters = { new Setter { Property = Label.XAlignProperty, Value = TextAlignment.End }, new Setter { Property = Label.YAlignProperty, Value = TextAlignment.Center }, new Setter { Property = Label.WidthRequestProperty, Value = 150 } } }; var labelName = new Label { Text = "Name:", Style = labelStyle }; entryName = new Entry { Placeholder = "Input your name", HorizontalOptions = LayoutOptions.FillAndExpand }; var labelBirthday = new Label { Text = "Birthday:", Style = labelStyle }; pickerBirthday = new DatePicker { Date = new DateTime(1990, 1, 1) }; var labelLike = new Label { Text = "Like Xamarin?", Style = labelStyle }; switchLike = new Switch { }; var saveButton = new Button { Text = "Save", HorizontalOptions = LayoutOptions.FillAndExpand }; saveButton.Clicked += saveButton_Clicked; var loadButton = new Button { Text = "Load", HorizontalOptions = LayoutOptions.FillAndExpand }; loadButton.Clicked += loadButton_Clicked; var clearButton = new Button { Text = "Clear", HorizontalOptions = LayoutOptions.FillAndExpand }; clearButton.Clicked += clearButton_Clicked; resultLabel = new Label { Text = "", FontSize = 30 }; Title = "Save to dictionary (C#)"; Content = new StackLayout { Padding = 10, Spacing = 10, Children = { new Label { Text = "DataSave Sample", FontSize = 40, HorizontalOptions = LayoutOptions.Center }, new StackLayout { Orientation = StackOrientation.Horizontal, Children = { labelName, entryName } }, new StackLayout { Orientation = StackOrientation.Horizontal, Children = { labelBirthday, pickerBirthday } }, new StackLayout { Orientation = StackOrientation.Horizontal, Children = { labelLike, switchLike } }, new StackLayout { Orientation = StackOrientation.Horizontal, Children = { saveButton, loadButton, clearButton } }, resultLabel } }; }
public DatePickerDemoPage() { Label header = new Label { Text = "DatePicker", FontSize = 50, FontAttributes = FontAttributes.Bold, HorizontalOptions = LayoutOptions.Center }; DatePicker datePicker = new DatePicker { Format = "D", VerticalOptions = LayoutOptions.CenterAndExpand }; // Build the page. this.Content = new StackLayout { Children = { header, datePicker } }; }
public void OnPickerClick(object sender, EventArgs e) { Xamarin.Forms.DatePicker model = Element; _dialog = new DatePickerDialog(Context, (o, d) => { model.Date = d.Date; EController.SetValueFromRenderer(VisualElement.IsFocusedProperty, false); Control.ClearFocus(); _dialog = null; }, this.Element.Date.Year, this.Element.Date.Month - 1, this.Element.Date.Day); _dialog.DatePicker.MaxDate = UnixTimestampFromDateTime(Element.MaximumDate); _dialog.DatePicker.MinDate = UnixTimestampFromDateTime(Element.MinimumDate); _dialog.SetButton(blankPicker.DoneButtonText, (k, p) => { this.Control.Text = _dialog.DatePicker.DateTime.ToString(Element.Format); Element.Date = _dialog.DatePicker.DateTime; blankPicker.SendDoneClicked(); }); _dialog.SetButton2(blankPicker.CancelButtonText, (s, el) => { blankPicker.SendCancelClicked(); }); _dialog.Show(); }
private void UpdateLastCompletedDate(object sender, EventArgs e) { Xamarin.Forms.DatePicker date = (Xamarin.Forms.DatePicker)sender; DateTime newDate = date.Date; completionDate = newDate; Console.WriteLine(completionDate); }
public dataPicker() { Grid gr = new Grid { RowDefinitions = { new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, }, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, } }; pick = new Xamarin.Forms.Picker { Title = "keeld" }; pick.Items.Add("C#"); pick.Items.Add("python"); pick.Items.Add("C++"); pick.Items.Add("VisualBasic"); pick.Items.Add("Java"); gr.Children.Add(pick, 0, 0); pick.SelectedIndexChanged += Pick_SelectedIndexChanged; editor = new Editor { Placeholder = "vali keel" }; editor = new Editor { Placeholder = "vali keel nimekirjas" }; gr.Children.Add(editor, 1, 0); dpicker = new DatePicker { Format = "D", MinimumDate = DateTime.Now.AddDays(-10), MaximumDate = DateTime.Now.AddDays(10), }; gr.Children.Add(dpicker, 1, 1); Content = gr; }
public BetPage() { try{ this.Title = "Test Title"; NavigationPage.SetHasNavigationBar (this, true); var numbersLabel = new Label { Text = "Numbers" }; var numbersEntry = new Entry (); numbersEntry.SetBinding(Entry.TextProperty, "Numbers"); var starsLabel = new Label { Text = "Stars" }; var starsEntry = new Entry (); starsEntry.SetBinding(Entry.TextProperty, "Stars"); var dateLabel = new Label { Text = "Date" }; var dateEntry = new DatePicker (); dateEntry.SetBinding (DatePicker.DateProperty, new Binding ("Date", BindingMode.TwoWay, new DateTimeToStringConverter (), null)); var saveButton = new Button { Text = "Save" }; saveButton.Clicked += (sender, e) => { var BetObject = (Bet)BindingContext; App.Database.SaveBet(BetObject); this.Navigation.PopAsync(); }; var deleteButton = new Button { Text = "Delete" }; deleteButton.Clicked += (sender, e) => { var BetObject = (Bet)BindingContext; App.Database.DeleteBet(BetObject.ID); this.Navigation.PopAsync(); }; var cancelButton = new Button { Text = "Cancel" }; cancelButton.Clicked += (sender, e) => { this.Navigation.PopAsync(); }; Content = new StackLayout { VerticalOptions = LayoutOptions.StartAndExpand, Padding = new Thickness(20), Children = { numbersLabel, numbersEntry, starsLabel, starsEntry, /*dateLabel, dateEntry,*/ saveButton, deleteButton, cancelButton } }; } catch(Exception exc){ System.Diagnostics.Debug.WriteLine (exc); } }
private void InitializeComponent() { this.LoadFromXaml(typeof(MediaDetailsView)); btnCancelM = this.FindByName<Button>("btnCancelM"); btnSaveM = this.FindByName<Button>("btnSaveM"); btnDeleteM = this.FindByName<Button>("btnDeleteM"); btnSelectPhoto = this.FindByName<Button>("btnSelectPhoto"); btnTakePhoto = this.FindByName<Button>("btnTakePhoto"); entryMediaDesc = this.FindByName<Entry>("entryMediaDesc"); DTPicker = this.FindByName<DatePicker>("DTPicker"); imgPhoto = this.FindByName<Image>("imgPhoto"); }
private void InitializeComponent() { this.LoadFromXaml(typeof(HomePage)); nombresEntry = this.FindByName<Entry>("nombresEntry"); apellidosEntry = this.FindByName<Entry>("apellidosEntry"); salarioEntry = this.FindByName<Entry>("salarioEntry"); fechaContratoDatePicker = this.FindByName<DatePicker>("fechaContratoDatePicker"); activoSwitch = this.FindByName<Switch>("activoSwitch"); nuevoButton = this.FindByName<Button>("nuevoButton"); datosListView = this.FindByName<ListView>("datosListView"); }
private void InitializeComponent() { this.LoadFromXaml(typeof(EditPage)); nombresEntry = this.FindByName<Entry>("nombresEntry"); apellidosEntry = this.FindByName<Entry>("apellidosEntry"); salarioEntry = this.FindByName<Entry>("salarioEntry"); fechaContratoDatePicker = this.FindByName<DatePicker>("fechaContratoDatePicker"); activoSwitch = this.FindByName<Switch>("activoSwitch"); actualizarButton = this.FindByName<Button>("actualizarButton"); borrarButton = this.FindByName<Button>("borrarButton"); }
public View CreateDatePickerFor(string propertyName, LayoutOptions layout) { DatePicker iiDatePicker = new DatePicker { HorizontalOptions = layout, BackgroundColor = Helper.Color.iiGreen.ToFormsColor(), }; iiDatePicker.SetBinding(DatePicker.DateProperty, propertyName); return iiDatePicker; }
private void InitializeComponent() { this.LoadFromXaml(typeof(CreateFootballPlayerPage)); ImagePicker = this.FindByName <Image>("ImagePicker"); ImagePickerTapGesture = this.FindByName <TapGestureRecognizer>("ImagePickerTapGesture"); FirstNamelbl = this.FindByName <Entry>("FirstNamelbl"); LastNamelbl = this.FindByName <Entry>("LastNamelbl"); DateOfBirthPicker = this.FindByName <DatePicker>("DateOfBirthPicker"); CountryPicker = this.FindByName <Picker>("CountryPicker"); DescriptionEditor = this.FindByName <Editor>("DescriptionEditor"); SavePlayerProfileBTN = this.FindByName <Button>("SavePlayerProfileBTN"); }
private void InitializeComponent() { this.LoadFromXaml(typeof(TimeLogDetailsView)); btnCancelSC = this.FindByName<Button>("btnCancelSC"); btnSaveSC = this.FindByName<Button>("btnSaveSC"); btnDeleteSC = this.FindByName<Button>("btnDeleteSC"); entryModelName = this.FindByName<Entry>("entryModelName"); PickerLogDate = this.FindByName<DatePicker>("PickerLogDate"); PickerLogTime = this.FindByName<TimePicker>("PickerLogTime"); EntryMinutes = this.FindByName<Entry>("EntryMinutes"); EntrySeconds = this.FindByName<Entry>("EntrySeconds"); entryBattery1Name = this.FindByName<Entry>("entryBattery1Name"); entryBattery2Name = this.FindByName<Entry>("entryBattery2Name"); }
protected override DatePickerDialog CreateDatePickerDialog(int year, int month, int day) { DatePicker view = Element; var dialog = new DatePickerDialog(Context, (o, e) => { view.Date = e.Date; Picker.SelectedDate = null; Picker.SelectedDate = e.Date; ((IElementController)view).SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false); }, year, month, day); return(dialog); }
} //end ctor private Layout BuildView() { this.BackgroundColor = AppColors.CONTENTLIGHTBKG; Label lblItem = new Label() { Text = "Product:", TextColor = AppColors.LABELBLUE }; Picker pickerItem = new Picker() { HorizontalOptions = LayoutOptions.FillAndExpand, BackgroundColor = AppColors.LABELGRAY }; foreach(var a in Order.ItemTypes) { pickerItem.Items.Add(a); } pickerItem.SetBinding(Picker.SelectedIndexProperty, "ItemIndex"); Label lblPrice = new Label() { Text = "Price:", TextColor = AppColors.LABELBLUE }; Entry entryPrice = new Entry() { HorizontalOptions = LayoutOptions.FillAndExpand, Keyboard = Keyboard.Numeric, BackgroundColor = AppColors.LABELGRAY }; entryPrice.SetBinding(Entry.TextProperty, "Price"); Label lblDateDue = new Label() { Text = "Date Due:", TextColor = AppColors.LABELBLUE }; DatePicker dateDue = new DatePicker() { HorizontalOptions = LayoutOptions.FillAndExpand, BackgroundColor = AppColors.LABELGRAY }; dateDue.SetBinding(DatePicker.DateProperty, "Order.DueDate"); Button btnOrder = new Button() { Text = "Place Order", HorizontalOptions = LayoutOptions.Center, TextColor = AppColors.LABELWHITE }; btnOrder.Clicked += btnOrder_Clicked; StackLayout stack = new StackLayout() { Padding = 10, Children = { lblItem, pickerItem, lblPrice, entryPrice, lblDateDue, dateDue, btnOrder } }; return stack; }
private void InitializeComponent() { this.LoadFromXaml(typeof(ActivityLogDetailsView)); btnCancelSC = this.FindByName<Button>("btnCancelSC"); btnSaveSC = this.FindByName<Button>("btnSaveSC"); btnDeleteSC = this.FindByName<Button>("btnDeleteSC"); entryActivityType = this.FindByName<Entry>("entryActivityType"); entryModelName = this.FindByName<Entry>("entryModelName"); PickerLogDate = this.FindByName<DatePicker>("PickerLogDate"); PickerLogTime = this.FindByName<TimePicker>("PickerLogTime"); lblDuration = this.FindByName<Label>("lblDuration"); EntryMinutes = this.FindByName<Entry>("EntryMinutes"); lblTimeColon = this.FindByName<Label>("lblTimeColon"); EntrySeconds = this.FindByName<Entry>("EntrySeconds"); lblBattery1 = this.FindByName<Label>("lblBattery1"); entryBattery1Name = this.FindByName<Entry>("entryBattery1Name"); lblBattery2 = this.FindByName<Label>("lblBattery2"); entryBattery2Name = this.FindByName<Entry>("entryBattery2Name"); }
private void InitializeComponent() { this.LoadFromXaml(typeof(RCInventoryDetailsView)); btnCancelSC = this.FindByName<Button>("btnCancelSC"); btnSaveSC = this.FindByName<Button>("btnSaveSC"); btnDeleteSC = this.FindByName<Button>("btnDeleteSC"); ItemCategory = this.FindByName<Label>("ItemCategory"); labelItemType = this.FindByName<Label>("labelItemType"); entryItemType = this.FindByName<Entry>("entryItemType"); entryItemName = this.FindByName<Entry>("entryItemName"); entryManufacturer = this.FindByName<Entry>("entryManufacturer"); btnListManuf = this.FindByName<Button>("btnListManuf"); lblBatteryNo = this.FindByName<Label>("lblBatteryNo"); EntryBatteryNo = this.FindByName<Entry>("EntryBatteryNo"); EntryMinutes = this.FindByName<Entry>("EntryMinutes"); EntrySeconds = this.FindByName<Entry>("EntrySeconds"); DTPicker = this.FindByName<DatePicker>("DTPicker"); btnNoOfFlights = this.FindByName<Button>("btnNoOfFlights"); labelNoOfFlights = this.FindByName<Label>("labelNoOfFlights"); btnGallery = this.FindByName<Button>("btnGallery"); }
public DateCell() { but = new DatePicker() { Format = "dd/MM/yyyy", WidthRequest = 400, VerticalOptions = LayoutOptions.CenterAndExpand, HeightRequest = 30, HorizontalOptions = LayoutOptions.CenterAndExpand, }; var layout = new StackLayout() { HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand, Children = { but } }; this.View = layout; }
public iOSDatePickerPageCS() { Xamarin.Forms.DatePicker datePicker = new Xamarin.Forms.DatePicker { MinimumDate = new DateTime(2020, 1, 1), MaximumDate = new DateTime(2020, 12, 31) }; Button button = new Button { Text = "Toggle DatePicker UpdateMode" }; button.Clicked += (sender, e) => { switch (datePicker.On <iOS>().UpdateMode()) { case UpdateMode.Immediately: datePicker.On <iOS>().SetUpdateMode(UpdateMode.WhenFinished); break; case UpdateMode.WhenFinished: datePicker.On <iOS>().SetUpdateMode(UpdateMode.Immediately); break; } }; datePicker.On <iOS>().SetUpdateMode(UpdateMode.WhenFinished); Title = "DatePicker UpdateMode"; Content = new StackLayout { Margin = new Thickness(10), Children = { datePicker, button } }; }
// Note that there are a couple of options for retrieving the selection value for // many of these views and those options will be placed in each of the two Label // views’ Text properties. public Controls() { eventValue = new Label(); eventValue.Text = "Value in Event"; pageValue = new Label(); pageValue.Text = "Value in Page"; Picker picker = new Picker { Title = "Option", VerticalOptions = LayoutOptions.CenterAndExpand }; var options = new List<string> { "First", "Second", "Third", "Fourth" }; foreach (string optionName in options) { picker.Items.Add(optionName); } picker.SelectedIndexChanged += (sender, args) => { pageValue.Text = picker.Items[picker.SelectedIndex]; }; DatePicker datePicker = new DatePicker { Format = "D", VerticalOptions = LayoutOptions.CenterAndExpand }; datePicker.DateSelected += (object sender, DateChangedEventArgs e) => { eventValue.Text = e.NewDate.ToString(); pageValue.Text = datePicker.Date.ToString(); }; TimePicker timePicker = new TimePicker { Format = "T", VerticalOptions = LayoutOptions.CenterAndExpand }; // no built-in TimeSelected event so use data-binding PropertyChanged event timePicker.PropertyChanged += (sender, e) => { if (e.PropertyName == TimePicker.TimeProperty.PropertyName) { pageValue.Text = timePicker.Time.ToString(); } }; // Stepper stepper = new Stepper(0 ,10 ,0 , 1); // alternative declaration Stepper stepper = new Stepper { Minimum = 0, Maximum = 10, Increment = 1, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.CenterAndExpand }; stepper.ValueChanged += (sender, e) => { eventValue.Text = String.Format("Stepper value is {0:F1}", e.NewValue); pageValue.Text = stepper.Value.ToString(); }; // Slider slider = new Slider (0 ,100 ,50); // alternative declaration Slider slider = new Slider { Minimum = 0, Maximum = 100, Value = 50, VerticalOptions = LayoutOptions.CenterAndExpand, WidthRequest = 300 }; slider.ValueChanged += (sender, e) => { eventValue.Text = String.Format("Slider value is {0:F1}", e.NewValue); pageValue.Text = slider.Value.ToString(); }; Switch switcher = new Switch { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.CenterAndExpand }; switcher.Toggled += (sender, e) => { eventValue.Text = String.Format("Switch is now {0}", e.Value); pageValue.Text = switcher.IsToggled.ToString(); }; this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5); this.Content = new StackLayout { HorizontalOptions = LayoutOptions.Center, Children = { eventValue, pageValue, picker, datePicker, timePicker, stepper, slider, switcher } }; }
public TodoItemPage() { this.SetBinding(ContentPage.TitleProperty, "Todo"); NavigationPage.SetHasNavigationBar(this, true); //task name var nameLabel = new Label { Text = "Name" }; var nameEntry = new Entry(); nameEntry.SetBinding(Entry.TextProperty, "Name"); //Notes var notesLabel = new Label { Text = "Notes" }; var notesEntry = new Entry(); notesEntry.SetBinding(Entry.TextProperty, "Notes"); //Category var categoryLabel = new Label { Text = "Category" }; var categoryPicker = new Picker { Title = "Category", VerticalOptions = LayoutOptions.CenterAndExpand }; foreach (var category in App.CategoryDatabase.GetCategories()) { categoryPicker.Items.Add(category.Name); } categoryPicker.SetBinding(Picker.SelectedIndexProperty, "CategoryId"); //var categoryPicker = new BindablePicker //{ // Title = "Category", // VerticalOptions = LayoutOptions.CenterAndExpand, // ItemsSource = App.CategoryDatabase.GetCategoryNames() //}; //categoryPicker.SetBinding(BindablePicker.SelectedItemProperty, "Category"); //Due date var dueDateLabel = new Label { Text = "Due Date" }; var dueDatePicker = new DatePicker { Format = "D", VerticalOptions = LayoutOptions.CenterAndExpand }; dueDatePicker.SetBinding(DatePicker.DateProperty, "DueDate"); //Reminder Date var reminderDateLabel = new Label { Text = " Set Reminder" }; var reminderDatePicker = new DatePicker { Format = "D", VerticalOptions = LayoutOptions.CenterAndExpand }; reminderDatePicker.SetBinding(DatePicker.DateProperty, "ReminderDate"); //Done var doneLabel = new Label { Text = "Done" }; var doneEntry = new Switch(); doneEntry.SetBinding(Switch.IsToggledProperty, "Done"); //Save var saveButton = new Button { Text = "Save" }; saveButton.Clicked += (sender, e) => { var todoItem = (TodoItem)BindingContext; App.Database.SaveItem(todoItem); this.Navigation.PopAsync(); }; Content = new StackLayout { VerticalOptions = LayoutOptions.StartAndExpand, Padding = new Thickness(20), Children = { nameLabel, nameEntry, notesLabel, notesEntry, categoryLabel, categoryPicker, dueDateLabel, dueDatePicker, reminderDateLabel, reminderDatePicker, doneLabel, doneEntry, saveButton } }; }
public NewPlayerPage() { this.BindingContext = new FootballPlayerViewModel (); BackgroundColor = Color.FromHex ("#008080"); Title = "Player Details"; Entry Player_FName = new Entry { Placeholder = "First Name" }; Entry Player_LName = new Entry { Placeholder = "Last Name" }; DatePicker Date_of_Birth = new DatePicker { MaximumDate = DateTime.Now }; Editor Description_Editor = new Editor (); string[] Country_Picker_array = new string[] { "Argentina", "Australia", "Belgium", "Brazil", "Canada", "China", "Croatia", "Denmark", "Ecuador", "Egypt", "El Salvador", "England", "Ethiopia", "Germany", "India", "Italy", "Japan", "Malasya", "Netherlands", "NewZealand", "Qatar", "South Africa" }; Picker Country_Picker = new Picker (); foreach (string country_string in Country_Picker_array) Country_Picker.Items.Add (country_string); Button Save_Button = new Button { Text = "Save Details", BackgroundColor = Color.White, BorderRadius = 5, HorizontalOptions = LayoutOptions.Center }; //Save_Button.Command = this.SetBinding (Button.CommandProperty,"SaveCommand"); Save_Button.Clicked += (object sender, EventArgs e) => { Player_FName.Unfocus (); Player_LName.Unfocus (); Description_Editor.Unfocus (); Country_Picker.Unfocus (); Date_of_Birth.Unfocus (); if (Player_FName.Text == null || Player_LName.Text == null) { DisplayAlert ("Warning", "Empty Player Name field", "Return"); } else if (Country_Picker.SelectedIndex == -1) { DisplayAlert ("Warning", "Empty Country field", "Return"); } else if (Description_Editor.Text == null) DisplayAlert ("Warning", "Empty Description field", "Return"); else { saveToDataBase (new FootballPlayer ( Player_FName.Text, Player_LName.Text, Date_of_Birth.Date.ToString("MMMM dd, yyyy"), Country_Picker_array [Country_Picker.SelectedIndex], Description_Editor.Text )); } }; StackLayout content_stacklayout = new StackLayout (); ScrollView Customer_Details_ScrollView = new ScrollView { WidthRequest = ((content_stacklayout.Width * 2) / 3), VerticalOptions = LayoutOptions.Center, Content = new StackLayout { VerticalOptions = LayoutOptions.Center, Children = { new Label { Text = "Player Name :" }, Player_FName, Player_LName, new Label { Text = "Date of Birth :" }, Date_of_Birth, new Label { Text = "Description :" }, Description_Editor, new Label { Text = "Country :" }, Country_Picker, Save_Button } } }; content_stacklayout.Children.Add (Customer_Details_ScrollView); Content = content_stacklayout; }
public DetailsPage() { var saveButton = new Button () { Text = "Save it!" }; CustomerName = new Entry { Placeholder = "Please enter your name" }; DOB = new DatePicker { Format = "D" }; Gender = new Switch { //HorizontalOptions =LayoutOptions }; Desc = new Entry { Text = "" , Placeholder = "Description" }; CountryList = new Picker { }; string[] countryStrings = new string[5]; countryStrings [0] = "India"; countryStrings [1] = "USA"; countryStrings [2] = "JAPAN"; countryStrings [3] = "UK"; countryStrings [4] = "Australia"; foreach (string country in countryStrings) { CountryList.Items.Add(country); } var maleFemale = new Label (); maleFemale.Text = "M"; CountryList.Title = "Select Country"; saveButton.Clicked += SaveButton_Clicked; AbsoluteLayout.SetLayoutBounds (maleFemale, new Rectangle (400F, 200F, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize)); // this.Content = new StackLayout { // //Spacing = 15, // //HorizontalOptions = LayoutOptions.CenterAndExpand, // Children = { // CustomerName // , // DOB, // // new Label{ // // Text ="Gender" // }, // Gender, // Desc, // maleFemale, // CountryList, // saveButton // // } // // }; var gen = new Label { Text = "Gender" }; RelativeLayout layout = new RelativeLayout {Padding=10}; layout.Children.Add (CustomerName,Constraint.Constant(80),Constraint.Constant(10)); layout.Children.Add(DOB,Constraint.Constant(80),Constraint.Constant(50)); layout.Children.Add(gen,Constraint.Constant(80),Constraint.Constant(90)); layout.Children.Add(Gender,Constraint.Constant(80),Constraint.Constant(130)); layout.Children.Add(Desc,Constraint.Constant(80),Constraint.Constant(210)); layout.Children.Add(maleFemale,Constraint.Constant(160),Constraint.Constant(90)); layout.Children.Add(CountryList,Constraint.Constant(80),Constraint.Constant(250)); layout.Children.Add(saveButton,Constraint.Constant(80),Constraint.Constant(290)); this.Content = layout; Gender.Toggled += (sender, e) => { if(Gender.IsToggled) { maleFemale.Text = "F"; } else { maleFemale.Text = "M"; } }; }
public dataPicker() { Grid gr = new Grid { RowDefinitions = { new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, }, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, } }; pick = new Xamarin.Forms.Picker { Title = "keeld" }; pick.Items.Add("C#"); pick.Items.Add("python"); pick.Items.Add("C++"); pick.Items.Add("VisualBasic"); pick.Items.Add("Java"); gr.Children.Add(pick, 0, 0); pick.SelectedIndexChanged += Pick_SelectedIndexChanged; editor = new Editor { Placeholder = "vali keel" }; editor = new Editor { Placeholder = "vali keel nimekirjas" }; gr.Children.Add(editor, 1, 0); dpicker = new DatePicker { Format = "D", MinimumDate = DateTime.Now.AddDays(-10), MaximumDate = DateTime.Now.AddDays(10), }; dpicker.DateSelected += Dpicker_DateSelected; gr.Children.Add(dpicker, 1, 1); entry = new Entry { Text = "vali kuupäev" }; timepicker = new TimePicker() { Time = new TimeSpan(DateTime.Now.Hour + 2, DateTime.Now.Minute, DateTime.Now.Second) }; Content = gr; frame = new Frame() { BorderColor = Color.Purple, HasShadow = true, BackgroundColor = Color.LightBlue, Content = new Label { Text = "хаю-хай" } }; }
public TodoItemPage () { this.SetBinding (ContentPage.TitleProperty, "Name"); NavigationPage.SetHasNavigationBar (this, true); var nameLabel = new Label { Text = "Name" }; var nameEntry = new Entry (); nameEntry.SetBinding (Entry.TextProperty, "Name"); var notesLabel = new Label { Text = "Notes" }; var notesEntry = new Entry (); notesEntry.SetBinding (Entry.TextProperty, "Notes"); var doneLabel = new Label { Text = "Done" }; var doneEntry = new Switch (); doneEntry.SetBinding (Switch.IsToggledProperty, "Done"); var saveButton = new Button { Text = "Save" }; saveButton.Clicked += (sender, e) => { var todoItem = (TodoItem)BindingContext; App.Database.SaveItem(todoItem); this.Navigation.PopAsync(); }; var deleteButton = new Button { Text = "Delete" }; deleteButton.Clicked += (sender, e) => { var todoItem = (TodoItem)BindingContext; App.Database.DeleteItem(todoItem.ID); this.Navigation.PopAsync(); }; var cancelButton = new Button { Text = "Cancel" }; cancelButton.Clicked += (sender, e) => { var todoItem = (TodoItem)BindingContext; this.Navigation.PopAsync(); }; var speakButton = new Button { Text = "Speak" }; speakButton.Clicked += (sender, e) => { var todoItem = (TodoItem)BindingContext; DependencyService.Get<ITextToSpeech>().Speak(todoItem.Name + " " + todoItem.Notes); }; nameLabel.Text = L10n.Localize("NameLabel", "Name"); notesLabel.Text = L10n.Localize("NotesLabel", "Notes"); doneLabel.Text = L10n.Localize("DoneLabel", "Done"); saveButton.Text = L10n.Localize ("SaveButton", "Save"); deleteButton.Text = L10n.Localize ("DeleteButton", "Delete"); // TODO: included as a 'test' for localizing the picker // currently not saved to database var dueDateLabel = new Label { Text = "Due" }; var dueDatePicker = new DatePicker (); Content = new StackLayout { VerticalOptions = LayoutOptions.StartAndExpand, Padding = new Thickness(20), Children = { nameLabel, nameEntry, notesLabel, notesEntry, doneLabel, doneEntry, dueDateLabel, dueDatePicker, saveButton, deleteButton, cancelButton, speakButton } }; }
public SignUp() { Label title = new Label { Text = "Sign Up", FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)), HorizontalOptions = LayoutOptions.Center, }; //Label and Entry for Name Label name = new Label { Text = "Name", FontSize = Device.GetNamedSize (NamedSize.Medium, typeof(Label)), HorizontalOptions = LayoutOptions.Center }; Entry nameEntry = new Entry { HorizontalOptions = LayoutOptions.Fill, }; nameEntry.SetBinding (Entry.TextProperty, "Name"); //Label and Entry for Email Label email = new Label { Text = "Email", FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), HorizontalOptions = LayoutOptions.Center }; Entry emailEntry = new Entry { HorizontalOptions = LayoutOptions.Fill, }; emailEntry.SetBinding (Entry.TextProperty, "Email"); //Label and DatePicker for Birthdate Label birthdate = new Label { Text = "Birthdate", FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), HorizontalOptions = LayoutOptions.Center }; DatePicker datePicker = new DatePicker { HorizontalOptions = LayoutOptions.CenterAndExpand, }; datePicker.SetBinding (DatePicker.DateProperty, "Birthdate"); //Button to save user Button saveButton = new Button { HorizontalOptions = LayoutOptions.Center, WidthRequest = 100, Text ="Save", BorderWidth = 1, }; saveButton.SetBinding (Button.CommandProperty, "SaveUserCommand"); //Set the binding context to the UserViewModel vm = new UserViewModel(); this.BindingContext = vm; //Add padding to support IPhone top bar this.Padding = new Thickness (0, Device.OnPlatform (20, 0, 0), 0, 0); StackLayout stack = new StackLayout { Children = {title, name, nameEntry, email, emailEntry, birthdate, datePicker, saveButton} }; this.Content = stack; //Listen for messages from the view model MessagingCenter.Subscribe<UserViewModel, string> (this, "save message", (sender, arg) => { if(arg.Equals("Empty fields")) DisplayAlert("Missing Fields", "Ensure all of the fields are completed", "Close"); if(arg.Equals("Invalid email")) DisplayAlert("Invalid Email", "Please, ensure your email address is correct", "Close"); if(arg.Equals("Success")){ DisplayAlert("Sign up successful", String.Format("Thank you {0} for signing up", ((UserViewModel)this.BindingContext).Name), "Close"); ((UserViewModel)this.BindingContext).Name=""; ((UserViewModel)this.BindingContext).Email=""; ((UserViewModel)this.BindingContext).Birthdate=DateTime.Now; } }); }
public static FluentDatePicker DatePicker(DatePicker instance = null) { return new FluentDatePicker (instance); }
public CadastroEdicaoPage() { try { this.BindingContext = model = App.Container.Resolve<CadastroViewModel>(); model.ConfiguraNavigation(this.Navigation); MessagingCenter.Subscribe<CategoriasPage,ICollection<Categoria>>(this, "gravarCategorias", (sender, arg) => { this.model.AdicionaCategoriasSelecionadas(arg); if (arg.Count > 1) this.btnCategorias.Text = String.Format("{0} Categorias selecionada", arg.Count); else this.btnCategorias.Text = String.Format("{0} Categoria selecionadas", arg.Count); }); var imgLogo = new Image { Source = ImageSource.FromResource(RetornaCaminhoImagem.GetImagemCaminho("logo_mini.png")), VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center }; sexoPicker = new PickerSexoMais(); if (Device.OS == TargetPlatform.Android) sexoPicker.Title = "Sexo"; sexoPicker.SetBinding<CadastroViewModel>(PickerSexoMais.SelectedIndexProperty, x => x.Usuario.Sexo, BindingMode.Default, new SexoValueConverter(), null); var nascimentoPicker = new DatePickerMais(); var entEmail = new Entry { Placeholder = AppResources.TextoPlaceHolderEmailCadastro, HorizontalOptions = LayoutOptions.FillAndExpand }; entEmail.SetBinding(Entry.TextProperty, "Email"); var entNome = new Entry { Placeholder = AppResources.TextoPlaceHolderNomeCadastro, HorizontalOptions = LayoutOptions.FillAndExpand }; entNome.SetBinding(Entry.TextProperty, "Nome"); var entDDD = new Entry { Placeholder = AppResources.TextoPlaceHolderDDDCadastro, }; entDDD.SetBinding(Entry.TextProperty, "DDD"); var entTelefone = new Entry { Placeholder = AppResources.TextoPlaceHolderTelefoneCadastro }; entTelefone.SetBinding(Entry.TextProperty, "Telefone"); var entMunicipio = new Entry { Placeholder = AppResources.TextoPlaceHolderMunicipioCadastro, HorizontalOptions = LayoutOptions.FillAndExpand }; entMunicipio.SetBinding(Entry.TextProperty, "Municipio"); btnCategorias = new Button { Text = AppResources.TextoPlaceHolderCategoriasCadastro, HorizontalOptions = LayoutOptions.FillAndExpand, Style = Estilos._estiloPadraoButtonFonteMenor }; dataNasc = new DatePicker(); sexoPickerDois = new PickerSexoMais(); gridWrapSexoNascimento = new Grid(); gridWrapSexoNascimento.Children.Add(sexoPicker, 0, 0); gridWrapSexoNascimento.Children.Add(nascimentoPicker, 1, 0); gridWrapSexoNascimentoEdicao = new Grid(); gridWrapSexoNascimentoEdicao.Children.Add(sexoPickerDois, 0, 0); gridWrapSexoNascimentoEdicao.Children.Add(dataNasc, 1, 0); var gridWrapDDDTelefone = new Grid(); gridWrapDDDTelefone.Children.Add(entDDD, 0, 0); gridWrapDDDTelefone.Children.Add(entTelefone, 1, 0); var btnCriar = new Button { Style = Estilos._estiloPadraoButton, Text = "Atualizar", HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Start }; btnCriar.Clicked += async (sender, e) => { var result = await model.AtualizarCadastro(model.Usuario, this.Navigation, gridWrapSexoNascimento.IsVisible ? nascimentoPicker.Date : dataNasc.Date, gridWrapSexoNascimento.IsVisible ? sexoPicker.SelectedIndex : sexoPickerDois.SelectedIndex); if (result) await this.Navigation.PushModalAsync(new MainPage()); }; var gridWrapButtons = new Grid { ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(0.5, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength(0.5, GridUnitType.Star) } }, RowDefinitions = { new RowDefinition { Height = GridLength.Auto } } }; //gridWrapButtons.Children.Add(btnVoltar, 0, 0); gridWrapButtons.Children.Add(btnCriar, 1, 0); var mainLayout = new StackLayout { Children = { imgLogo, gridWrapSexoNascimento, gridWrapSexoNascimentoEdicao, btnCategorias, entEmail, entNome, gridWrapDDDTelefone, entMunicipio, gridWrapButtons }, VerticalOptions = LayoutOptions.FillAndExpand, Spacing = 5, Padding = new Thickness(5, 50, 5, 50) }; this.Content = new ScrollView { Content = mainLayout }; } catch (Exception ex) { Insights.Report(ex); } }
public MainPage() { InitializeComponent (); BirthDate = BirthDatePicker; }
public LeaveRequestForm() { try { var lblApplyLeave = new Label { Text = "apply leave", Font = Font.SystemFontOfSize(20), WidthRequest = 150, TextColor = Color.White, XAlign = TextAlignment.Start, YAlign = TextAlignment.Center, }; var lblLeaveNo = new Label { Text = "7", Font = Font.SystemFontOfSize(40), TextColor = Color.FromHex("#344153"), VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.End, XAlign = TextAlignment.End, YAlign = TextAlignment.Center }; var lblLeft = new Label { Text = "left", Font = Font.SystemFontOfSize(12), TextColor = Color.White, HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Center, XAlign = TextAlignment.End, YAlign = TextAlignment.End }; var headingPanel = new StackLayout { Padding = 10, HeightRequest = 50, BackgroundColor = Color.FromHex("#00B4F0"), Orientation = StackOrientation.Horizontal, Children = { lblApplyLeave, lblLeaveNo, lblLeft } }; var lblFormName = new Label { Text = "Leave Application Form", TextColor = Color.White, HorizontalOptions = LayoutOptions.Center, }; var lblFrom = new Label { Text = "From", TextColor = Color.White, VerticalOptions = LayoutOptions.Start }; fromDate = new DatePicker { MinimumDate = DateTime.Now.Date, }; fromPicker = GetPicker(); toPicker = GetPicker(); var lblTo = new Label { Text = "To", TextColor = Color.White }; toDate = new DatePicker { MinimumDate = DateTime.Now.Date }; var lblLeaveReason = new Label { Text = "Leave Reason", TextColor = Color.White }; ////var pnlLeaveReason = new StackLayout ////{ //// Orientation = StackOrientation.Horizontal, //// Spacing = 10 ////}; txtLeaveReason = new Entry { TextColor = Color.White }; var applyButton = new Button { Text = "Apply", BackgroundColor = Color.FromHex("77D065"), HorizontalOptions = LayoutOptions.FillAndExpand }; applyButton.Clicked += applyButton_Clicked; //btnPanel.Children.Add(applyButton, 0, 0); var cancelButton = new Button { Text = "Cancel", BackgroundColor = Color.FromHex("77D065"), HorizontalOptions = LayoutOptions.FillAndExpand }; cancelButton.Clicked += cancelButton_Clicked; var buttonPanel = new StackLayout { Spacing = 10, Padding = 5, Children = { applyButton, cancelButton }, Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, }; var stackPanel = new StackLayout { Spacing = 5, Orientation = StackOrientation.Vertical, Children = { headingPanel, lblFormName, lblFrom, fromDate, fromPicker, lblTo, toDate, toPicker, lblLeaveReason, txtLeaveReason, buttonPanel } }; this.Content = new ScrollView { Padding = new Thickness(20), Content = stackPanel }; } catch (Exception e) { } }
public SaveByVMCS() { BindingContext = vm; var labelStyle = new Style(typeof(Label)) { Setters = { new Setter { Property = Label.XAlignProperty, Value = TextAlignment.End }, new Setter { Property = Label.YAlignProperty, Value = TextAlignment.Center }, new Setter { Property = Label.WidthRequestProperty, Value = 150 } } }; var labelName = new Label { Text = "Name:", Style = labelStyle }; entryName = new Entry { Placeholder = "Input your name", HorizontalOptions = LayoutOptions.FillAndExpand }; entryName.SetBinding(Entry.TextProperty, "Name", mode: BindingMode.TwoWay); var labelBirthday = new Label { Text = "Birthday:", Style = labelStyle }; var pickerBirthday = new DatePicker { }; pickerBirthday.SetBinding(DatePicker.DateProperty, "Birthday", mode: BindingMode.TwoWay); var labelLike = new Label { Text = "Like Xamarin?", Style = labelStyle }; var switchLike = new Switch { }; switchLike.SetBinding(Switch.IsToggledProperty, "Like", mode: BindingMode.TwoWay); var saveButton = new Button { Text = "Save", HorizontalOptions = LayoutOptions.FillAndExpand }; saveButton.Clicked += saveButton_Clicked; var loadButton = new Button { Text = "Load", HorizontalOptions = LayoutOptions.FillAndExpand }; loadButton.Clicked += loadButton_Clicked; var clearButton = new Button { Text = "Clear", HorizontalOptions = LayoutOptions.FillAndExpand }; clearButton.Clicked += clearButton_Clicked; resultLabel = new Label { Text = "", FontSize = 30 }; Title = "Save to dic by vm (C#)"; Content = new StackLayout { Padding = 10, Spacing = 10, Children = { new Label { Text = "DataSave Sample", FontSize = 40, HorizontalOptions = LayoutOptions.Center }, new StackLayout { Orientation = StackOrientation.Horizontal, Children = { labelName, entryName } }, new StackLayout { Orientation = StackOrientation.Horizontal, Children = { labelBirthday, pickerBirthday } }, new StackLayout { Orientation = StackOrientation.Horizontal, Children = { labelLike, switchLike } }, new StackLayout { Orientation = StackOrientation.Horizontal, Children = { saveButton, loadButton, clearButton } }, resultLabel } }; }
private void CreateControls() { var list = new ListView(ListViewCachingStrategy.RecycleElement) { ItemTemplate = new DataTemplate(typeof(ExpenseCell)) }; list.ItemSelected += (sender, e) => { ((ListView)sender).SelectedItem = null; }; list.SetBinding<ExpenseViewModel>(ListView.ItemsSourceProperty, vm => vm.Expenses); this.SetBinding<ExpenseViewModel>(TitleProperty, vm => vm.Title); var footer = new Grid { /*HeightRequest = 120,*/ BackgroundColor = AppColors.Gray.MultiplyAlpha(0.5d), RowSpacing = 10, Padding = new Thickness(0, 0, 0, 10) }; footer.RowDefinitions.Add(new RowDefinition { Height = 1 }); footer.RowDefinitions.Add(new RowDefinition()); footer.RowDefinitions.Add(new RowDefinition()); footer.RowDefinitions.Add(new RowDefinition()); footer.ColumnDefinitions.Add(new ColumnDefinition()); footer.ColumnDefinitions.Add(new ColumnDefinition()); var topBorder = new StackLayout { BackgroundColor = AppColors.DarkGray }; footer.Children.Add(topBorder); Grid.SetColumn(topBorder, 0); Grid.SetRow(topBorder, 0); Grid.SetColumnSpan(topBorder, 2); var picker = new DatePicker { Format = "MMMMM yyyy", BackgroundColor = Color.Transparent, HorizontalOptions = LayoutOptions.Center }; footer.Children.Add(picker); picker.SetBinding<ExpenseViewModel>(DatePicker.DateProperty, vm => vm.SelectedDate); Grid.SetRow(picker, 1); Grid.SetColumnSpan(picker, 2); var manGroup = new StackLayout { Orientation = StackOrientation.Horizontal, Padding = new Thickness(10, 0) }; var manLabel = CreateLabel("Ben :", 18, AppColors.DarkGray); manLabel.FontAttributes = FontAttributes.Bold; var manValue = CreateLabel("", 16, AppColors.Blue); manValue.SetBinding<ExpenseViewModel>(Label.TextProperty, vm => vm.ManTotal, BindingMode.Default, new FloatCurrenyValueConverter()); manGroup.Children.Add(manLabel); manGroup.Children.Add(manValue); footer.Children.Add(manGroup); Grid.SetColumn(manGroup, 0); Grid.SetRow(manGroup, 2); var womanGroup = new StackLayout { Orientation = StackOrientation.Horizontal, Padding = new Thickness(10, 0) }; var womanLabel = CreateLabel("Soph :", 18, AppColors.DarkGray); womanLabel.FontAttributes = FontAttributes.Bold; var womanValue = CreateLabel("", 16, AppColors.Red); womanValue.SetBinding<ExpenseViewModel>(Label.TextProperty, vm => vm.WomanTotal, BindingMode.Default, new FloatCurrenyValueConverter()); womanGroup.Children.Add(womanLabel); womanGroup.Children.Add(womanValue); footer.Children.Add(womanGroup); Grid.SetColumn(womanGroup, 0); Grid.SetRow(womanGroup, 3); var totalGroup = new StackLayout { Orientation = StackOrientation.Horizontal, Padding = new Thickness(10, 0) }; var totalLabel = CreateLabel("TOTAL :", 18, AppColors.DarkGray); totalLabel.FontAttributes = FontAttributes.Bold; var totalValue = CreateLabel("", 16, AppColors.DarkGray.MultiplyAlpha(0.8d)); totalValue.SetBinding<ExpenseViewModel>(Label.TextProperty, vm => vm.BothTotal, BindingMode.Default, new FloatCurrenyValueConverter()); totalGroup.Children.Add(totalLabel); totalGroup.Children.Add(totalValue); footer.Children.Add(totalGroup); Grid.SetColumn(totalGroup, 1); Grid.SetRow(totalGroup, 2); var differenceGroup = new StackLayout { Orientation = StackOrientation.Horizontal, Padding = new Thickness(10, 0) }; var differenceLabel = CreateLabel("Différence :", 18, AppColors.DarkGray); differenceLabel.FontAttributes = FontAttributes.Bold; var differenceValue = CreateLabel("", 16, AppColors.Orange); differenceValue.SetBinding<ExpenseViewModel>(Label.TextProperty, vm => vm.Diff); differenceGroup.Children.Add(differenceLabel); differenceGroup.Children.Add(differenceValue); footer.Children.Add(differenceGroup); Grid.SetColumn(differenceGroup, 1); Grid.SetRow(differenceGroup, 3); var all = new StackLayout { Orientation = StackOrientation.Vertical }; all.Children.Add(list); all.Children.Add(footer); Content = all; ToolbarItems.Add(new ToolbarItem { Command = _vm.ShowAddCommand, Icon = new FileImageSource { File = "add.png" } }); }
public void buildForm() { var mainLayout = new StackLayout { Padding = 20 }; this.Title = definition.Title; foreach (var el in definition.Elements) { switch (el.Type) { //Add Label case "Label": var label = new Label { Text = ((FormLabel)el).LabelText, FontAttributes = FontAttributes.Bold, HorizontalOptions = LayoutOptions.FillAndExpand }; //label.SetBinding(Label.TextProperty,$"FormElementCollection[{i}]",BindingMode.TwoWay); mainLayout.Children.Add(label); break; //Add Entry case "Entry": mainLayout.Children.Add(new Label { Text = ((FormEntryField)el).LabelText, HorizontalOptions = LayoutOptions.FillAndExpand }); var _entry = new Entry { Placeholder = ((FormEntryField)el).PlaceHolderText, HorizontalOptions = LayoutOptions.FillAndExpand, Keyboard = el.NumKeyboard ? Keyboard.Telephone : Keyboard.Default }; _entry.TextChanged += (sender, e) => { ((FormEntryField)el).Text = e.NewTextValue; }; mainLayout.Children.Add(_entry); break; //Add text field case "TextField": mainLayout.Children.Add(new Label { Text = ((FormTextField)el).LabelText, HorizontalOptions = LayoutOptions.FillAndExpand }); var editor = new EditorGrows //Editor { //Text = ((FormTextField)el).LabelText, HorizontalOptions = LayoutOptions.FillAndExpand }; editor.TextChanged += (sender, e) => { ((FormTextField)el).Text = e.NewTextValue; }; mainLayout.Children.Add(editor); break; case "Picker": mainLayout.Children.Add(new Label { Text = ((Picker)el).LabelText, HorizontalOptions = LayoutOptions.FillAndExpand }); var _picker = new Xamarin.Forms.Picker(); _picker.HorizontalOptions = LayoutOptions.FillAndExpand; foreach (var option in ((Picker)el).Values) { _picker.Items.Add(option); } _picker.SelectedIndexChanged += (sender, e) => { ((Picker)el).SelectedValue = ((Picker)el).Values[((Xamarin.Forms.Picker)sender).SelectedIndex]; }; mainLayout.Children.Add(_picker); break; // ADD Switch case "Switch": mainLayout.Children.Add(new Label { Text = ((FormSwitch)el).LabelText, HorizontalOptions = LayoutOptions.FillAndExpand }); var _switch = new Switch { IsToggled = ((FormSwitch)el).DefaultValue, HorizontalOptions = LayoutOptions.FillAndExpand }; _switch.Toggled += (object sender, ToggledEventArgs e) => { ((FormSwitch)el).Value = e.Value; }; mainLayout.Children.Add(_switch); break; // Add Datepicker case "DatePicker": mainLayout.Children.Add(new Label { Text = ((DatePicker)el).LabelText, HorizontalOptions = LayoutOptions.FillAndExpand }); var datePicker = new Xamarin.Forms.DatePicker { HorizontalOptions = LayoutOptions.FillAndExpand }; datePicker.DateSelected += (sender, e) => { ((DatePicker)el).SelectedDate = e.NewDate; }; mainLayout.Children.Add(datePicker); break; default: break; } } this.Content = new ScrollView { Content = mainLayout }; }
public StartPageCS() { this.allEventsInfo = new ObservableCollection<AllEventsInfo>(); cities = new HashSet<string>(); ChooseCity(); ngWords = new NGWords(); ngWordsList = new HashSet<string>(); #region // 日付指定レイヤー dateLayer dateFrom = new DatePicker { Date = DateTime.Now, Format = "M/d", WidthRequest = Device.OnPlatform(75, 75, 120), }; dateTo = new DatePicker { Date = DateTime.Now.AddDays(2), Format = "M/d", WidthRequest = Device.OnPlatform(75, 75, 120), MinimumDate = dateFrom.Date, }; dateFrom.PropertyChanged += (object sender, PropertyChangedEventArgs e) => { if (dateFrom.Date > dateTo.Date) dateTo.Date = dateFrom.Date.AddDays(2); dateTo.MinimumDate = dateFrom.Date.AddDays(1); }; if (Device.OS == TargetPlatform.Windows) { dateTo.WidthRequest = 120; dateFrom.WidthRequest = 120; } var searchButton = new Button { Text = "検索", WidthRequest = 100, VerticalOptions = LayoutOptions.Center, }; searchButton.Clicked += dateLayer_SearchButton_Clicked; dateLayer = new StackLayout { IsVisible = false, Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.Center, Children = { dateFrom, new Label { Text = "~", YAlign = TextAlignment.Center }, dateTo, searchButton, } }; #endregion #region // 検索レイヤー searchLayer searchLayer = new SearchBar { IsVisible = false, Placeholder = "' 'か','でOR検索、&でAND検索", }; searchLayer.SearchButtonPressed += SearchLayer_SearchButtonPressed; #endregion // クルクルレイヤー waitingLayout waitingLayout = new WaitingLayout(); list = new ListView { HasUnevenRows = true, ItemTemplate = new DataTemplate(typeof(EventCell)), // PostCell テンプレート ItemsSource = allEventsInfo, }; list.ItemTapped += list_ItemTapped; list.ItemAppearing += List_ItemAppearing; #region ToolbarItems ToolbarItems.Add(new ToolbarItem { Icon = "Search.png", Text = "絞り込み検索", Command = new Command(() => { this.dateLayer.IsVisible = false; if (this.searchLayer.IsVisible) { this.searchLayer.IsVisible = false; } else { searchLayer.IsVisible = true; } }) }); ToolbarItems.Add(new ToolbarItem { Icon = "Calendar.png", Text = "日付選択", Command = new Command(() => { this.searchLayer.IsVisible = false; if (this.dateLayer.IsVisible) { this.dateLayer.IsVisible = false; } else { this.dateLayer.IsVisible = true; } }) }); ToolbarItems.Add(new ToolbarItem { Icon = "Setting.png", Text = "設定", Command = new Command(() => { // 各種データを初期化して次のページへ n = 0; allEventsInfo.Clear(); list.ItemsSource = allEventsInfo; // ここまで Navigation.PushAsync(new SettingPageCS()); }), }); #endregion Title = " IT 勉強会検索"; Content = new StackLayout { Children = { searchLayer, dateLayer, list, waitingLayout, }, }; }
public Osnova() { InitializeComponent(); Grid grd = new Grid(); Picker pick; //------------------------------------------------------------ //Колонны ColumnDefinition colDef1 = new ColumnDefinition(); ColumnDefinition colDef2 = new ColumnDefinition(); grd.ColumnDefinitions.Add(colDef1); grd.ColumnDefinitions.Add(colDef2); //Ряды RowDefinition rowDef1 = new RowDefinition(); RowDefinition rowDef2 = new RowDefinition(); RowDefinition rowDef3 = new RowDefinition(); grd.RowDefinitions.Add(rowDef1); grd.RowDefinitions.Add(rowDef2); grd.RowDefinitions.Add(rowDef3); //------------------------------------------------------------- //Datepicker date = new DatePicker { Format = "D", MinimumDate = DateTime.Now.AddDays(-10), MaximumDate = DateTime.Now.AddDays(+10), }; date.DateSelected += Date_DateSelected; grd.Children.Add(date, 0, 1); //Picker pick = new Picker { Title = "Choose language" }; pick.Items.Add("C#"); pick.Items.Add("Python"); pick.Items.Add("C++"); pick.Items.Add("BisualBasic"); pick.Items.Add("Java"); pick.SelectedIndexChanged += Pick_SelectedIndexChanged; grd.Children.Add(pick, 0, 0); //Editor edit = new Editor { Placeholder = "Choose language \nIn left column" }; grd.Children.Add(edit, 1, 0); //Entry entr = new Entry { Text = "Choose date", }; grd.Children.Add(entr, 1, 1); //Frame frm = new Frame { BackgroundColor = Color.LightGray }; { }; grd.Children.Add(frm, 0, 2); Grid.SetColumnSpan(frm, 2); //Timepicker СИНХРОНИЗИРОВАННОЕ ВРЕМЯ!!! ------------------------------------------------------------------------------------------------- /* time = new TimePicker * { * Time = new TimeSpan(18, 0, 0), * Time = new TimeSpan (DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second) * }; * grd.Children.Add(time, 1, 1); */ Content = grd; }
public DatePickerHandler(NativeComponentRenderer renderer, XF.DatePicker datePickerControl) : base(renderer, datePickerControl) { DatePickerControl = datePickerControl ?? throw new ArgumentNullException(nameof(datePickerControl)); Initialize(renderer); }
public DaysBetweenDatesPage() { // Create DatePicker views. fromDatePicker = new DatePicker { Format = dateFormat, HorizontalOptions = LayoutOptions.Center }; fromDatePicker.DateSelected += OnDateSelected; toDatePicker = new DatePicker { Format = dateFormat, HorizontalOptions = LayoutOptions.Center }; toDatePicker.DateSelected += OnDateSelected; // Create Label for displaying result. resultLabel = new Label { Font = Font.SystemFontOfSize(NamedSize.Large), HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.CenterAndExpand }; // Build the page. this.Content = new StackLayout { Children = { // Program title and underline. new StackLayout { VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.Center, Children = { new Label { Text = "Days Between Dates", Font = Font.SystemFontOfSize(NamedSize.Large, FontAttributes.Bold), TextColor = Color.Accent }, new BoxView { HeightRequest = 3, Color = Color.Accent } } }, // "From" DatePicker view. new StackLayout { VerticalOptions = LayoutOptions.CenterAndExpand, Children = { new Label { Text = "From:", HorizontalOptions = LayoutOptions.Center }, fromDatePicker } }, // "To" DatePicker view. new StackLayout { VerticalOptions = LayoutOptions.CenterAndExpand, Children = { new Label { Text = "To:", HorizontalOptions = LayoutOptions.Center }, toDatePicker } }, // Label for result. resultLabel } }; // Initialize results display. OnDateSelected(null, null); }