blob: 8449213732b69b9f852a6b97ef752e416b2d3e85 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms.Internals;
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;
}
}
}
|