summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls/GalleryPages/ControlTemplatePage.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Controls/GalleryPages/ControlTemplatePage.cs')
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/ControlTemplatePage.cs48
1 files changed, 48 insertions, 0 deletions
diff --git a/Xamarin.Forms.Controls/GalleryPages/ControlTemplatePage.cs b/Xamarin.Forms.Controls/GalleryPages/ControlTemplatePage.cs
new file mode 100644
index 00000000..32eb2a19
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/ControlTemplatePage.cs
@@ -0,0 +1,48 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls.GalleryPages
+{
+ internal class ControlTemplatePage : ContentPage
+ {
+ [Preserve (AllMembers = true)]
+ class MyLayout : StackLayout
+ {
+ public MyLayout ()
+ {
+ Children.Add (new Label {Text = "Before"});
+ Children.Add (new ContentPresenter ());
+ Children.Add (new Label {Text = "After"});
+ }
+ }
+
+ [Preserve (AllMembers = true)]
+ class MyOtherLayout : StackLayout
+ {
+ public MyOtherLayout ()
+ {
+ Children.Add (new Entry {Text = "Before"});
+ Children.Add (new ContentPresenter ());
+ Children.Add (new Entry {Text = "After"});
+ }
+ }
+
+ public ControlTemplatePage ()
+ {
+ var button = new Button { Text = "Replace Template" };
+ var content = new ContentView {
+ Content = button,
+ ControlTemplate = new ControlTemplate (typeof (MyLayout))
+ };
+
+ button.Clicked += (sender, args) => {
+ content.ControlTemplate = new ControlTemplate (typeof (MyOtherLayout));
+ };
+
+ Content = content;
+ }
+ }
+}