Skip to content

Instantly share code, notes, and snippets.

@Adam--
Created October 3, 2019 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Adam--/3b6d3d8c258d59f39d06a4ee35f9ae17 to your computer and use it in GitHub Desktop.
Save Adam--/3b6d3d8c258d59f39d06a4ee35f9ae17 to your computer and use it in GitHub Desktop.
Create view model and set binding context in view's XAML
<!-- From https://github.com/jamesmontemagno/app-pretty-weather/blob/master/PrettyWeather/PrettyWeather/MainPage.xaml -->
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
x:Class="PrettyWeather.MainPage"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:pancake="clr-namespace:Xamarin.Forms.PancakeView;assembly=Xamarin.Forms.PancakeView"
xmlns:converters="clr-namespace:PrettyWeather.Converters"
xmlns:viewmodel="clr-namespace:PrettyWeather.ViewModel"
xmlns:model="clr-namespace:PrettyWeather.Model"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Name="WeatherPage"
mc:Ignorable="d">
<ContentPage.BindingContext>
<viewmodel:WeatherViewModel Temp="61"/>
</ContentPage.BindingContext>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment