Modified XamlSamplePage to properly create the Ooui.Forms page element with the input of any Xamarin.Forms Page. Added a sample project to test DisplayAlert

(cherry picked from commit dcda89e4f29ab6cff246788db6ecdcee632cabce)
This commit is contained in:
Andrew Hoefling 2017-11-17 05:29:35 +00:00
parent 2b0e1ce206
commit 7c315661b9
7 changed files with 70 additions and 27 deletions

View File

@ -1,17 +0,0 @@
using System;
using Ooui;
using Xamarin.Forms;
namespace Samples
{
public class ButtonXamlPageSample : ISample
{
public string Title => "Xamarin.Forms Button XAML";
public Ooui.Element CreateElement ()
{
var page = new ButtonXaml.ButtonXamlPage ();
return page.GetOouiElement ();
}
}
}

View File

@ -0,0 +1,13 @@
<?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="Samples.DisplayAlertSample">
<ContentPage.Content>
<StackLayout>
<Label Text="Welcome to DisplayAlert Sample!" />
<Button Text="Tap for Display Alert"
HeightRequest="30"
Clicked="OnButtonClicked" />
</StackLayout>
</ContentPage.Content>
</ContentPage>

View File

@ -0,0 +1,21 @@
using System;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace Samples
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class DisplayAlertSample : ContentPage
{
public DisplayAlertSample ()
{
InitializeComponent ();
}
public async void OnButtonClicked(object sender, EventArgs args)
{
await DisplayAlert("Alert Message", "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa.", "OK");
}
}
}

View File

@ -30,7 +30,10 @@ namespace Samples
new DrawSample().Publish();
new FilesSample().Publish();
UI.Present ("/todo");
var sample = new XamlPageSample();
UI.Publish("/display-alert", sample.CreateElement(new DisplayAlertSample()));
UI.Present ("/display-alert", sample);
Console.ReadLine ();
}

View File

@ -17,10 +17,19 @@
<EmbeddedResource Include="**/*.xaml" />
</ItemGroup>
<ItemGroup>
<Compile Update="DisplayAlertSample.xaml.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="ButtonXamlPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="DisplayAlertSample.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
</ItemGroup>
<PropertyGroup>

14
Samples/XamlPageSample.cs Normal file
View File

@ -0,0 +1,14 @@
using Xamarin.Forms;
namespace Samples
{
public class XamlPageSample
{
public string Title => "Xamarin.Forms Button XAML";
public Ooui.Element CreateElement (Page page)
{
return page.GetOouiElement ();
}
}
}