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

@ -2,12 +2,12 @@
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="ButtonXaml.ButtonXamlPage"> x:Class="ButtonXaml.ButtonXamlPage">
<StackLayout Padding="20"> <StackLayout Padding="20">
<Label Text="Welcome to Xamarin.Forms!"/> <Label Text="Welcome to Xamarin.Forms!"/>
<Label x:Name="LabelCount" Text="Click Count: 0"/> <Label x:Name="LabelCount" Text="Click Count: 0"/>
<Button Text="Tap for click count!" <Button Text="Tap for click count!"
HeightRequest="30" HeightRequest="30"
Clicked="OnButtonClicked" /> Clicked="OnButtonClicked" />
</StackLayout> </StackLayout>
</ContentPage> </ContentPage>

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

@ -25,12 +25,15 @@ namespace Samples
} }
} }
new ButtonSample ().Publish (); new ButtonSample().Publish();
new TodoSample ().Publish (); new TodoSample().Publish();
new DrawSample ().Publish (); new DrawSample().Publish();
new FilesSample ().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 (); Console.ReadLine ();
} }

View File

@ -17,10 +17,19 @@
<EmbeddedResource Include="**/*.xaml" /> <EmbeddedResource Include="**/*.xaml" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Compile Update="DisplayAlertSample.xaml.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Update="ButtonXamlPage.xaml"> <EmbeddedResource Update="ButtonXamlPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator> <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Update="DisplayAlertSample.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
</ItemGroup> </ItemGroup>
<PropertyGroup> <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 ();
}
}
}