From df76ec4c773804f20ba4dd81ca3067220cbdf0e9 Mon Sep 17 00:00:00 2001 From: syneffort Date: Wed, 11 Jan 2023 18:07:24 +0900 Subject: [PATCH] button, label fontsize (Device.GetNamedSize) --- .../XamarinStudy/XamarinStudy/App.xaml.cs | 15 ++++++- .../Views/SampleElementPage1.xaml | 17 ++++++++ .../Views/SampleElementPage1.xaml.cs | 29 ++++++++++++++ .../XamarinStudy/Views/SampleElementPage2.cs | 39 +++++++++++++++++++ .../XamarinStudy/XamarinStudy.csproj | 9 +++++ 5 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 XamarinStudy/XamarinStudy/XamarinStudy/Views/SampleElementPage1.xaml create mode 100644 XamarinStudy/XamarinStudy/XamarinStudy/Views/SampleElementPage1.xaml.cs create mode 100644 XamarinStudy/XamarinStudy/XamarinStudy/Views/SampleElementPage2.cs diff --git a/XamarinStudy/XamarinStudy/XamarinStudy/App.xaml.cs b/XamarinStudy/XamarinStudy/XamarinStudy/App.xaml.cs index 47fd77c..3dccbac 100644 --- a/XamarinStudy/XamarinStudy/XamarinStudy/App.xaml.cs +++ b/XamarinStudy/XamarinStudy/XamarinStudy/App.xaml.cs @@ -15,17 +15,30 @@ namespace XamarinStudy DependencyService.Register(); //MainPage = new AppShell(); + //MainPage = new SampleContentPage(); + //MainPage = new NavigationPage(new SampleToolbarPage()); + //MainPage = new SampleTabPage(); + //TabbedPage tabbed = new TabbedPage(); //tabbed.Children.Add(new SampleContentPage() { Title = "Page1" }); //tabbed.Children.Add(new SampleToolbarPage() { Title = "Page2" }); //MainPage = tabbed; + //MainPage = new SampleCarouselPage(); + //MainPage = new SampleFlyoutPage(); + //MainPage = new SampleFlyoutPage2(); - MainPage = new NavigationPage(new SampleNavigationPage()); + + //MainPage = new NavigationPage(new SampleNavigationPage()); + + TabbedPage tabbed = new TabbedPage(); + tabbed.Children.Add(new SampleElementPage1() { Title = "XAML" }); + tabbed.Children.Add(new SampleElementPage2() { Title = "CS" }); + MainPage = tabbed; } protected override void OnStart() diff --git a/XamarinStudy/XamarinStudy/XamarinStudy/Views/SampleElementPage1.xaml b/XamarinStudy/XamarinStudy/XamarinStudy/Views/SampleElementPage1.xaml new file mode 100644 index 0000000..bc47ffb --- /dev/null +++ b/XamarinStudy/XamarinStudy/XamarinStudy/Views/SampleElementPage1.xaml @@ -0,0 +1,17 @@ + + + + + + + + \ No newline at end of file diff --git a/XamarinStudy/XamarinStudy/XamarinStudy/Views/SampleElementPage1.xaml.cs b/XamarinStudy/XamarinStudy/XamarinStudy/Views/SampleElementPage1.xaml.cs new file mode 100644 index 0000000..a21d74f --- /dev/null +++ b/XamarinStudy/XamarinStudy/XamarinStudy/Views/SampleElementPage1.xaml.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using Xamarin.Forms; +using Xamarin.Forms.Xaml; + +namespace XamarinStudy.Views +{ + [XamlCompilation(XamlCompilationOptions.Compile)] + public partial class SampleElementPage1 : ContentPage + { + public SampleElementPage1() + { + InitializeComponent(); + BackgroundColor = Color.White; + } + + private void chageBackgroundColorButton_Clicked(object sender, EventArgs e) + { + if (BackgroundColor == Color.White) + BackgroundColor = Color.Black; + else + BackgroundColor = Color.White; + } + } +} \ No newline at end of file diff --git a/XamarinStudy/XamarinStudy/XamarinStudy/Views/SampleElementPage2.cs b/XamarinStudy/XamarinStudy/XamarinStudy/Views/SampleElementPage2.cs new file mode 100644 index 0000000..cd067c7 --- /dev/null +++ b/XamarinStudy/XamarinStudy/XamarinStudy/Views/SampleElementPage2.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Xamarin.Forms; + +namespace XamarinStudy.Views +{ + public class SampleElementPage2 : ContentPage + { + public SampleElementPage2() + { + BackgroundColor = Color.White; + + Button changeBackgroundColorButton = new Button() { Text = "Change background color", BackgroundColor = Color.DarkViolet, FontSize = 30 }; + 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 label2 = new Label() { Text = "CS 20 Label", TextColor = Color.Red, BackgroundColor = Color.DeepSkyBlue, FontSize = 30 }; + Content = new StackLayout + { + Children = + { + changeBackgroundColorButton, + label1, + label2 + } + }; + } + + private void ChangeBackgroundColorButton_Clicked(object sender, EventArgs e) + { + if (BackgroundColor == Color.White) + BackgroundColor = Color.DarkSlateGray; + else + BackgroundColor = Color.White; + } + } +} \ No newline at end of file diff --git a/XamarinStudy/XamarinStudy/XamarinStudy/XamarinStudy.csproj b/XamarinStudy/XamarinStudy/XamarinStudy/XamarinStudy.csproj index 24d100b..ff7a85a 100644 --- a/XamarinStudy/XamarinStudy/XamarinStudy/XamarinStudy.csproj +++ b/XamarinStudy/XamarinStudy/XamarinStudy/XamarinStudy.csproj @@ -10,10 +10,19 @@ + + + SampleElementPage1.xaml + + + MSBuild:UpdateDesignTimeXaml + + MSBuild:UpdateDesignTimeXaml + MSBuild:UpdateDesignTimeXaml