XAML Code
- <?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:DatePicker" x:Class="DatePicker.MainPage">
- <StackLayout HorizontalOptions="Center" VerticalOptions="Center">
- <DatePicker x:Name="MainDatePicker" MinimumDate="1/1/2018" MaximumDate="12/31/2020" DateSelected="MainDatePicker_DateSelected" />
- <Label x:Name="MainLabel" FontSize="20" TextColor="Blue" /> </StackLayout>
- </ContentPage>
Now, open MainPage.xaml.cs file for writing the code.
C# Code
C# Code
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Xamarin.Forms;
- namespace DatePicker {
- public partial class MainPage: ContentPage {
- public MainPage() {
- InitializeComponent();
- }
- private void MainDatePicker_DateSelected(object sender, DateChangedEventArgs e) {
- MainLabel.Text = e.NewDate.ToLongDateString();
- }
- }
- }
No comments:
Post a Comment