summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.ControlGallery.WP8/BrokenNativeControl.cs
diff options
context:
space:
mode:
authorJason Smith <jason.smith@xamarin.com>2016-03-22 13:02:25 -0700
committerJason Smith <jason.smith@xamarin.com>2016-03-22 16:13:41 -0700
commit17fdde66d94155fc62a034fa6658995bef6fd6e5 (patch)
treeb5e5073a2a7b15cdbe826faa5c763e270a505729 /Xamarin.Forms.ControlGallery.WP8/BrokenNativeControl.cs
downloadxamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.tar.gz
xamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.tar.bz2
xamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.zip
Initial import
Diffstat (limited to 'Xamarin.Forms.ControlGallery.WP8/BrokenNativeControl.cs')
-rw-r--r--Xamarin.Forms.ControlGallery.WP8/BrokenNativeControl.cs56
1 files changed, 56 insertions, 0 deletions
diff --git a/Xamarin.Forms.ControlGallery.WP8/BrokenNativeControl.cs b/Xamarin.Forms.ControlGallery.WP8/BrokenNativeControl.cs
new file mode 100644
index 00000000..b05c12cb
--- /dev/null
+++ b/Xamarin.Forms.ControlGallery.WP8/BrokenNativeControl.cs
@@ -0,0 +1,56 @@
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media;
+
+namespace Xamarin.Forms.ControlGallery.WP8
+{
+ internal class BrokenNativeControl : Panel
+ {
+ public BrokenNativeControl ()
+ {
+ _textBlock = new TextBlock {
+ MinHeight = 0,
+ MaxHeight = double.PositiveInfinity,
+ MinWidth = 0,
+ MaxWidth = double.PositiveInfinity,
+ FontSize = 24,
+ HorizontalAlignment = HorizontalAlignment.Center
+ };
+
+ Children.Add (_textBlock);
+
+ Background = new RadialGradientBrush (Colors.Green, Colors.Blue);
+ }
+
+ public static readonly DependencyProperty TextProperty = DependencyProperty.Register (
+ "Text", typeof(string), typeof(BrokenNativeControl), new PropertyMetadata (default(string), PropertyChangedCallback));
+
+ static void PropertyChangedCallback (DependencyObject dependencyObject,
+ DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
+ {
+ ((BrokenNativeControl)dependencyObject)._textBlock.Text = (string)dependencyPropertyChangedEventArgs.NewValue;
+ }
+
+ public string Text
+ {
+ get { return (string)GetValue (TextProperty); }
+ set { SetValue (TextProperty, value); }
+ }
+
+ readonly TextBlock _textBlock;
+
+ protected override System.Windows.Size ArrangeOverride (System.Windows.Size finalSize)
+ {
+ _textBlock.Arrange (new Rect (0, 0, finalSize.Width, finalSize.Height));
+ return finalSize;
+ }
+
+ protected override System.Windows.Size MeasureOverride (System.Windows.Size availableSize)
+ {
+ _textBlock.Measure (availableSize);
+
+ // This deliberately does something wrong so we can demo fixing it
+ return new System.Windows.Size (600, _textBlock.DesiredSize.Height);
+ }
+ }
+} \ No newline at end of file