Please watch tutorial for complete detail:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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:MvvmExample1" | |
xmlns:sys="clr-namespace:System;assembly=mscorlib" | |
x:Class="MvvmExample1.MainPage"> | |
<!--It is a program with out view model--> | |
<!--Here’s a program that defines an XML namespace declaration for the System namespace:--> | |
<StackLayout BindingContext="{x:Static sys:DateTime.Now}" | |
HorizontalOptions="Center" | |
VerticalOptions="Center"> | |
<!--The program can use x:Static to obtain the current date and time from the static DateTime.Now property | |
and set that DateTime value to the BindingContext on a StackLayout--> | |
<Label Text="{Binding Year, StringFormat='The year is {0}'}" /> | |
<Label Text="{Binding StringFormat='The month is {0:MMMM}'}" /> | |
<!--DateTime value itself is used for the StringFormat--> | |
<Label Text="{Binding Day, StringFormat='The day is {0}'}" /> | |
<Label Text="{Binding StringFormat='The time is {0:T}'}" /> | |
</StackLayout> | |
</ContentPage> | |
<!--the big problem is that the date and time are set once when the page is first built, and never change:--> | |
No comments:
Post a Comment