summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.ControlGallery.WindowsPhone
diff options
context:
space:
mode:
authorSamantha Houts <samantha@teamredwall.com>2016-09-27 18:12:49 (GMT)
committerJason Smith <jason.smith@xamarin.com>2016-09-27 18:12:49 (GMT)
commitee3c84f05175934a9d847a3d867e370c4b301a99 (patch)
tree7a7f246dcc0c3e70ed533415da5941838e16ef4e /Xamarin.Forms.ControlGallery.WindowsPhone
parent3e0ee965d710768f1c434b469f8c1c8371b7659a (diff)
downloadxamarin-forms-ee3c84f05175934a9d847a3d867e370c4b301a99.zip
xamarin-forms-ee3c84f05175934a9d847a3d867e370c4b301a99.tar.gz
xamarin-forms-ee3c84f05175934a9d847a3d867e370c4b301a99.tar.bz2
[Win] Will arrange native children of custom renderers (opt-in) (#322)
* Add repro for 42602 * [Win] Add option to arrange native children * [Win] Don't allocate arrangedChildren unless required
Diffstat (limited to 'Xamarin.Forms.ControlGallery.WindowsPhone')
-rw-r--r--Xamarin.Forms.ControlGallery.WindowsPhone/CustomRenderers.cs57
-rw-r--r--Xamarin.Forms.ControlGallery.WindowsPhone/Xamarin.Forms.ControlGallery.WindowsPhone.csproj1
2 files changed, 58 insertions, 0 deletions
diff --git a/Xamarin.Forms.ControlGallery.WindowsPhone/CustomRenderers.cs b/Xamarin.Forms.ControlGallery.WindowsPhone/CustomRenderers.cs
new file mode 100644
index 0000000..2f6cae9
--- /dev/null
+++ b/Xamarin.Forms.ControlGallery.WindowsPhone/CustomRenderers.cs
@@ -0,0 +1,57 @@
+´╗┐using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Media;
+using Windows.UI.Xaml.Shapes;
+using Xamarin.Forms.Platform.WinRT;
+
+[assembly: ExportRenderer(typeof(Xamarin.Forms.Controls.Bugzilla42602.TextBoxView), typeof(Xamarin.Forms.ControlGallery.WindowsPhone.TextBoxViewRenderer))]
+namespace Xamarin.Forms.ControlGallery.WindowsPhone
+{
+ public class TextBoxViewRenderer : BoxViewRenderer
+ {
+ Canvas m_Canvas;
+
+ protected override void OnElementChanged(ElementChangedEventArgs<BoxView> e)
+ {
+ base.OnElementChanged(e);
+
+ ArrangeNativeChildren = true;
+
+ if (m_Canvas != null)
+ Children.Remove(m_Canvas);
+
+ m_Canvas = new Canvas()
+ {
+ Width = 200,
+ Height = 200,
+ Background = new SolidColorBrush(global::Windows.UI.Color.FromArgb(0, 255, 255, 255)),
+ IsHitTestVisible = false
+ };
+
+ Children.Add(m_Canvas);
+
+ //ellipse
+ Shape ellipse = new Ellipse()
+ {
+ Width = 100,
+ Height = 100,
+ Fill = new SolidColorBrush(global::Windows.UI.Color.FromArgb(255, 255, 0, 0)),
+
+ };
+ Canvas.SetLeft(ellipse, 0);
+ Canvas.SetTop(ellipse, 0);
+ m_Canvas.Children.Add(ellipse);
+
+ //text
+ TextBlock text = new TextBlock()
+ {
+ FontSize = 50,
+ FontWeight = global::Windows.UI.Text.FontWeights.Normal,
+ Text = "hello world",
+ Foreground = new SolidColorBrush(global::Windows.UI.Color.FromArgb(255, 255, 0, 0))
+ };
+ Canvas.SetLeft(text, 0);
+ Canvas.SetTop(text, 150);
+ m_Canvas.Children.Add(text);
+ }
+ }
+}
diff --git a/Xamarin.Forms.ControlGallery.WindowsPhone/Xamarin.Forms.ControlGallery.WindowsPhone.csproj b/Xamarin.Forms.ControlGallery.WindowsPhone/Xamarin.Forms.ControlGallery.WindowsPhone.csproj
index a856543..349b0b4 100644
--- a/Xamarin.Forms.ControlGallery.WindowsPhone/Xamarin.Forms.ControlGallery.WindowsPhone.csproj
+++ b/Xamarin.Forms.ControlGallery.WindowsPhone/Xamarin.Forms.ControlGallery.WindowsPhone.csproj
@@ -117,6 +117,7 @@
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="BrokenNativeControl.cs" />
+ <Compile Include="CustomRenderers.cs" />
<Compile Include="MainPage.xaml.cs">
<DependentUpon>MainPage.xaml</DependentUpon>
</Compile>