Thursday, 12 July 2018

MVVM Example 1 with out Model and ViewModel

Please watch tutorial for complete detail:
<?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:-->
view raw MainPage.xaml hosted with ❤ by GitHub

No comments:

Post a Comment