Skip to content

Instantly share code, notes, and snippets.

@RedTahr
Created July 15, 2015 21:06
Show Gist options
  • Save RedTahr/499a68b80d76a738dc5d to your computer and use it in GitHub Desktop.
Save RedTahr/499a68b80d76a738dc5d to your computer and use it in GitHub Desktop.
Xamarin.Forms DerivedPage.xaml/cs from BasePage, Binding ViewModel in XAML.
<?xml version="1.0" encoding="utf-8" ?>
<derived:BasePage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="....AboutPage"
xmlns:local="clr-namespace:...;assembly=..."
xmlns:derived="clr-namespace:....View;assembly=..."
BindingContext="{x:Static local:App.AboutViewModel}"
Title="About">
<StackLayout Orientation="Vertical" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<Label Text="{Binding Detail}"/>
<Label Text="{Binding TofS}">
<Label.GestureRecognizers>
<TapGestureRecognizer Command="{Binding TofSCommand}" />
</Label.GestureRecognizers>
</Label>
</Label>
</StackLayout>
</derived:BasePage>
namespace ... {
public partial class AboutPage : BasePage {
public AboutPage() {
InitializeComponent();
((AboutViewModel)BindingContext).set(this); // AboutViewModel is public static in the App.cs for the XAML reference below.
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment