Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MainPage.xaml.cs
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Xamarin.Forms;
- namespace TelaApp
- {
- public partial class MainPage : ContentPage
- {
- public Color BoxColor { get; set; }
- public Keyboard KeyboardPersonalizado { get; set; }
- public TimeSpan TimeSpan { get; set; }
- public MainPage()
- {
- InitializeComponent();
- BoxColor = Color.FromRgb(200, 100, 100);
- TimeSpan = new TimeSpan(22, 35, 00);
- KeyboardPersonalizado = Keyboard.Email;
- BindingContext = this;
- }
- private void NewEntryTextoModificado(object sender, TextChangedEventArgs textChangedEventArgs)
- {
- var texto = textChangedEventArgs.NewTextValue;
- System.Diagnostics.Debug.WriteLine("texto modificado " + texto);
- }
- private void NewEntryTextoCompleto(object sender, EventArgs eventArgs)
- {
- var texto = entryUm.Text;
- System.Diagnostics.Debug.WriteLine("texto concluído " + texto);
- }
- private void NewButtonClicado(object sender, EventArgs eventArgs)
- {
- var valor = entryUm.Text.ToString();
- System.Diagnostics.Debug.WriteLine("Botão clicado! " + valor + " ??");
- }
- private void Editor_OnCompleted(object sender, EventArgs e)
- {
- System.Diagnostics.Debug.WriteLine("texto completo");
- }
- private void Editor_OnTextChanged(object sender, TextChangedEventArgs e)
- {
- System.Diagnostics.Debug.WriteLine("texto editado");
- }
- private void Slider_OnValueChanged(object sender, ValueChangedEventArgs e)
- {
- System.Diagnostics.Debug.WriteLine("Valor antigo era " + e.OldValue);
- System.Diagnostics.Debug.WriteLine("Valor novo é " + e.NewValue);
- }
- private void Stepper_OnValueChanged(object sender, ValueChangedEventArgs e)
- {
- System.Diagnostics.Debug.WriteLine("valor antigo era " + e.OldValue);
- System.Diagnostics.Debug.WriteLine("Novo valor é " + e.NewValue);
- }
- private void Switch_OnToggled(object sender, ToggledEventArgs e)
- {
- System.Diagnostics.Debug.WriteLine("Status atual do switch: " + e.Value);
- }
- private void SearchBar_OnTextChanged(object sender, TextChangedEventArgs e)
- {
- System.Diagnostics.Debug.WriteLine("Texto que estava no elemento: " + e.OldTextValue);
- System.Diagnostics.Debug.WriteLine("Texto que está no elemento: " + e.NewTextValue);
- }
- private void SearchBar_OnSearchButtonPressed(object sender, EventArgs e)
- {
- System.Diagnostics.Debug.WriteLine("Texto no elemento: " + ((SearchBar)sender).Text);
- }
- private void DatePicker_OnDateSelected(object sender, DateChangedEventArgs e)
- {
- System.Diagnostics.Debug.WriteLine($"Data antiga: {e.OldDate.ToString("yy-MM-dd")}");
- System.Diagnostics.Debug.WriteLine($"Data nova: {e.NewDate.ToString("yy-MM-dd")}");
- }
- private void Picker_OnSelectedIndexChanged(object sender, EventArgs e)
- {
- System.Diagnostics.Debug.WriteLine($"Índice escolhido do picker: {((Picker)sender).SelectedIndex}");
- System.Diagnostics.Debug.WriteLine($"Elemento escolhido do picker: {((Picker)sender).Items[((Picker)sender).SelectedIndex]}");
- }
- }
- }
- --------------------------------
- MainPage.xaml
- <?xml version="1.0" encoding="utf-8" ?>
- <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
- xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
- xmlns:local="clr-namespace:TelaApp"
- x:Class="NovoApp.MainPage">
- <ScrollView>
- <StackLayout
- HorizontalOptions="Center"
- VerticalOptions="Center">
- <Label Text="Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Finish"
- LineBreakMode="WordWrap"
- VerticalOptions="Center"
- HorizontalOptions="Center"
- FontSize="15"
- TextColor="#c864c8"/>
- <Label Text="Label 2. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet."
- LineBreakMode="WordWrap"
- VerticalOptions="Center"
- HorizontalOptions="Center"
- FontSize="15"
- TextColor="#999"/>
- <Entry HorizontalOptions="FillAndExpand"
- x:Name="entryUm"
- VerticalOptions="Center"
- Placeholder="Digite o texto aqui"
- Completed="NewEntryTextoCompleto"
- TextChanged="NewEntryTextoModificado"
- Keyboard="{Binding KeyboardPersonalizado}" />
- <Button Text="Meu Botao"
- HorizontalOptions="FillAndExpand"
- VerticalOptions="Center"
- Clicked="NewButtonClicado" />
- <Editor
- FontSize="35"
- FontAttributes="Italic"
- Text="teste"
- Completed="Editor_OnCompleted"
- TextChanged="Editor_OnTextChanged"
- />
- <ActivityIndicator
- VerticalOptions="Center"
- HorizontalOptions="Center"
- IsRunning="True"
- IsVisible="True" />
- <BoxView
- VerticalOptions = "Center"
- HorizontalOptions="Center"
- WidthRequest="200"
- HeightRequest="350"
- Color ="{Binding BoxColor}"/>
- <ProgressBar
- Progress="0.5"
- HorizontalOptions="Fill"
- VerticalOptions="Center"
- />
- <Slider
- Minimum="0"
- Maximum="125"
- VerticalOptions="Center"
- HorizontalOptions="Fill"
- Value="57"
- ValueChanged="Slider_OnValueChanged"
- />
- <Switch
- HorizontalOptions="Center"
- VerticalOptions="Center"
- IsToggled="True"
- Toggled="Switch_OnToggled"
- />
- <Stepper
- Maximum="10"
- Minimum="1"
- Increment="0.4"
- Value="5"
- VerticalOptions="Center"
- HorizontalOptions="Center"
- ValueChanged="Stepper_OnValueChanged"
- />
- <SearchBar
- HorizontalOptions="Fill"
- VerticalOptions="Center"
- CancelButtonColor="Black"
- Placeholder="Digite o termo de busca"
- PlaceholderColor="Green"
- FontSize="25"
- FontAttributes="Bold"
- TextChanged="SearchBar_OnTextChanged"
- SearchButtonPressed="SearchBar_OnSearchButtonPressed"
- />
- <TimePicker
- VerticalOptions="Center"
- HorizontalOptions="Fill"
- Time="{Binding TimeSpan}"
- Format="HH:mm"
- />
- <DatePicker
- MinimumDate="2016/01/01"
- MaximumDate="2016/01/31"
- Format="yyyy/MM/dd"
- HorizontalOptions="Fill"
- VerticalOptions="Center"
- DateSelected="DatePicker_OnDateSelected"
- />
- <Picker
- VerticalOptions="Center"
- HorizontalOptions="Fill"
- SelectedIndexChanged="Picker_OnSelectedIndexChanged">
- <Picker.Items>
- <x:String>Opção 1</x:String>
- <x:String>Opção 2</x:String>
- <x:String>Opção 3</x:String>
- </Picker.Items>
- </Picker>
- </StackLayout>
- </ScrollView>
- </ContentPage>
Advertisement
Add Comment
Please, Sign In to add comment