Skip to content

Instantly share code, notes, and snippets.

@muojp
Created December 4, 2014 13:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save muojp/4f28cbc8bf5f64ed7684 to your computer and use it in GitHub Desktop.
Save muojp/4f28cbc8bf5f64ed7684 to your computer and use it in GitHub Desktop.
Sketching w/ Xamarin.Forms XAML
using Xamarin.Forms;
using System.Reflection;
using System.Runtime.CompilerServices;
using Xamarin.Forms.Xaml;
var xaml = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<ContentPage xmlns=""http://xamarin.com/schemas/2014/forms""
xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml""
x:Class=""XamlSamples.HelloXamlPage""
Title=""Hello XAML Page""
Padding=""10, 40, 10, 10"">
<Label Text=""Hello, XAML Sketch!!""
VerticalOptions=""Start""
XAlign=""Center""
Rotation=""15""
IsVisible=""true""
Font=""Bold, 80""
TextColor=""Red"" />
</ContentPage>";
var page = new ContentPage{Padding = new Thickness(0,20,0,0)};
var s = (
((MethodInfo)(
((TypeInfo)(
(Assembly.Load(new AssemblyName("Xamarin.Forms.Xaml, Version=1.2.3.0, Culture=neutral, PublicKeyToken=null"))
.GetTypes()
.Where(t => t.FullName == "Xamarin.Forms.Xaml.Extensions")
.First()
)
)).DeclaredMembers
.Where(t => !((MethodInfo)t).Attributes.HasFlag(System.Reflection.MethodAttributes.Family))
.First()
)).MakeGenericMethod(typeof(ContentPage))
).Invoke(null, new object[]{page, xaml}) != null;
RootPage.Children.Add(page);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment