slider, stepper

main
syneffort 2 years ago
parent 206740eb9a
commit db3def4399
  1. 8
      XamarinStudy/XamarinStudy/XamarinStudy/Views/SampleElementPage1.xaml
  2. 5
      XamarinStudy/XamarinStudy/XamarinStudy/Views/SampleElementPage1.xaml.cs
  3. 14
      XamarinStudy/XamarinStudy/XamarinStudy/Views/SampleElementPage2.cs

@ -7,16 +7,18 @@
<Button x:Name="chageBackgroundColorButton" Text="Change background color" TextColor="White" BackgroundColor="Salmon" BorderWidth="15" CornerRadius="50" Clicked="chageBackgroundColorButton_Clicked"> <Button x:Name="chageBackgroundColorButton" Text="Change background color" TextColor="White" BackgroundColor="Salmon" BorderWidth="15" CornerRadius="50" Clicked="chageBackgroundColorButton_Clicked">
</Button> </Button>
<Label Text="This is Lable" TextColor="DarkSlateBlue" BackgroundColor="LightPink" FontSize="Large" FontAttributes="Bold"/> <Label x:Name="lbl1" Text="This is Lable" TextColor="DarkSlateBlue" BackgroundColor="LightPink" FontSize="Large" FontAttributes="Bold"/>
<Label Text="This is Lable" TextColor="DarkSlateBlue" BackgroundColor="LightPink" FontSize="Large" FontAttributes="Bold" HorizontalTextAlignment="End"/> <Label Text="This is Lable" TextColor="DarkSlateBlue" BackgroundColor="LightPink" FontSize="Large" FontAttributes="Bold" HorizontalTextAlignment="End"/>
<Label Text="This is Lable" TextColor="DarkSlateBlue" BackgroundColor="LightPink" FontSize="Large" FontAttributes="Bold" HorizontalTextAlignment="Start"/> <Label Text="This is Lable" TextColor="DarkSlateBlue" BackgroundColor="LightPink" FontSize="Large" FontAttributes="Bold" HorizontalTextAlignment="Start"/>
<Label Text="This is Lable" TextColor="DarkSlateBlue" BackgroundColor="LightPink" FontSize="Large" FontAttributes="Italic" HorizontalTextAlignment="Center"/> <Label Text="This is Lable" TextColor="DarkSlateBlue" BackgroundColor="LightPink" FontSize="Large" FontAttributes="Italic" HorizontalTextAlignment="Center"/>
<Label Text="This is 30 Lable" TextColor="Red" BackgroundColor="LightPink" FontSize="30" HorizontalTextAlignment="Center"/> <Label Text="This is 30 Lable" TextColor="Red" BackgroundColor="LightPink" FontSize="30" HorizontalTextAlignment="Center"/>
<Entry Placeholder="Input Text" TextColor="Salmon" FontSize="Large" FontAttributes="Bold" Keyboard="Text"/> <Entry Placeholder="Input Text" TextColor="Salmon" FontSize="Large" FontAttributes="Bold" Keyboard="Text"/>
<Entry Placeholder="Input Number" TextColor="Red" FontSize="Large" FontAttributes="Bold" Keyboard="Numeric"/> <Entry Placeholder="Input Number" BindingContext="{x:Reference stepper1}" TextColor="Red" FontSize="{Binding Value}" FontAttributes="Bold" Keyboard="Numeric"/>
<Editor Placeholder="Input Message" TextColor="Red" BackgroundColor="{OnPlatform Android=Blue,UWP=White}" FontSize="Large" FontAttributes="Bold" HeightRequest="250"/> <Editor Placeholder="Input Message" BindingContext="{x:Reference slider1}" TextColor="Red" BackgroundColor="{OnPlatform Android=Blue,UWP=White}" FontSize="{Binding Value}" FontAttributes="Bold" HeightRequest="250"/>
<Slider x:Name="slider1" Maximum="100" Minimum="10" Value="15" MinimumTrackColor="Salmon" MaximumTrackColor="DarkRed"/>
<Stepper x:Name="stepper1" Maximum="50" Minimum="5" Increment="5" Value="20" ValueChanged="stepper1_ValueChanged"/>
</StackLayout> </StackLayout>
</ContentPage.Content> </ContentPage.Content>
</ContentPage> </ContentPage>

@ -25,5 +25,10 @@ namespace XamarinStudy.Views
else else
BackgroundColor = Color.White; BackgroundColor = Color.White;
} }
private void stepper1_ValueChanged(object sender, ValueChangedEventArgs e)
{
lbl1.Text = e.NewValue.ToString("N2");
}
} }
} }

@ -17,6 +17,7 @@ namespace XamarinStudy.Views
changeBackgroundColorButton.Clicked += ChangeBackgroundColorButton_Clicked; changeBackgroundColorButton.Clicked += ChangeBackgroundColorButton_Clicked;
Label label1 = new Label() { Text = "CS Label", TextColor = Color.Red, BackgroundColor = Color.DeepSkyBlue, FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)) }; Label label1 = new Label() { Text = "CS Label", TextColor = Color.Red, BackgroundColor = Color.DeepSkyBlue, FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)) };
Label label2 = new Label() { Text = "CS 20 Label", TextColor = Color.Red, BackgroundColor = Color.DeepSkyBlue, FontSize = 30 }; Label label2 = new Label() { Text = "CS 20 Label", TextColor = Color.Red, BackgroundColor = Color.DeepSkyBlue, FontSize = 30 };
Editor editor = new Editor() Editor editor = new Editor()
{ {
Placeholder = "Multi-line input", Placeholder = "Multi-line input",
@ -33,6 +34,16 @@ namespace XamarinStudy.Views
editor.TextColor = Color.White; editor.TextColor = Color.White;
} }
Slider slider = new Slider()
{
Maximum = 30,
Minimum = 5,
Value = 10,
MinimumTrackColor = Color.Pink,
MaximumTrackColor = Color.Red,
};
slider.ValueChanged += (s, e) => editor.Text = e.NewValue.ToString("N2");
Content = new StackLayout Content = new StackLayout
{ {
Children = Children =
@ -40,7 +51,8 @@ namespace XamarinStudy.Views
changeBackgroundColorButton, changeBackgroundColorButton,
label1, label1,
label2, label2,
editor editor,
slider
} }
}; };
} }

Loading…
Cancel
Save