/Xamarin.Forms.Calendar

This is a Calendar control that works within the Xamarin.Forms framework. It works on all platforms including iOS, Android and Windows Phone.

Primary LanguageC#

What the app looks like on each platform(these are real native UI components):

Alt text

The common code that used for the UI:

public class SampleCalendarPage : ContentPage 
{
	CalendarView _calendarView;
	StackLayout _stacker;

	public SampleCalendarPage ()
	{
		Title = "Calendar Sample";

		_stacker = new StackLayout ();
		Content = _stacker;

		_calendarView = new CalendarView() {
			VerticalOptions = LayoutOptions.Start,
			HorizontalOptions = LayoutOptions.CenterAndExpand
		};
		_stacker.Children.Add (_calendarView);
		_calendarView.DateSelected += (object sender, DateTime e) => {
			_stacker.Children.Add(new Label() 
				{ 
					Text = "Date Was Selected" + e.ToString("d"),
					VerticalOptions = LayoutOptions.Start,
					HorizontalOptions = LayoutOptions.CenterAndExpand,
				});
		};

	}
}

The (Android)platform code:

Xamarin.Forms.Forms.Init (this, bundle);
SetPage (App.GetMainPage ());

The (iOS)platform code:

window.RootViewController = App.GetMainPage ().CreateViewController ();

The (Windows Phone)platform code

Content = Xamarin.Forms.CalendarSampleApp.App.GetMainPage().ConvertPageToUIElement(this);

Now this is a trivial app, but as you can imagine as the application becomes more complex your UI code will stay in your common library and work across all platforms.

Please see this blog post for more info:

http://www.michaelridland.com/xamarin/xamarin-forms-contest/