From 4f282cd0a067a53abd2c35a000f9e6b201aab301 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Sat, 28 Nov 2015 20:06:15 +0300 Subject: [PATCH] Design properties now can be applied to Control --- src/Perspex.Application/Designer/Design.cs | 36 +++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Perspex.Application/Designer/Design.cs b/src/Perspex.Application/Designer/Design.cs index a31f791f9d..72bb23c067 100644 --- a/src/Perspex.Application/Designer/Design.cs +++ b/src/Perspex.Application/Designer/Design.cs @@ -12,42 +12,42 @@ namespace Perspex public static bool IsDesignMode { get; internal set; } public static readonly PerspexProperty HeightProperty = PerspexProperty - .RegisterAttached("Height", typeof (Design)); + .RegisterAttached("Height", typeof (Design)); - public static void SetHeight(TopLevel topLevel, double value) + public static void SetHeight(Control control, double value) { - topLevel.SetValue(HeightProperty, value); + control.SetValue(HeightProperty, value); } - public static double GetHeight(TopLevel topLevel) + public static double GetHeight(Control control) { - return (double) topLevel.GetValue(HeightProperty); + return control.GetValue(HeightProperty); } public static readonly PerspexProperty WidthProperty = PerspexProperty - .RegisterAttached("Width", typeof(Design)); + .RegisterAttached("Width", typeof(Design)); - public static void SetWidth(TopLevel topLevel, double value) + public static void SetWidth(Control control, double value) { - topLevel.SetValue(WidthProperty, value); + control.SetValue(WidthProperty, value); } - public static double GetWidth(TopLevel topLevel) + public static double GetWidth(Control control) { - return (double)topLevel.GetValue(WidthProperty); + return control.GetValue(WidthProperty); } public static readonly PerspexProperty DataContextProperty = PerspexProperty - .RegisterAttached("DataContext", typeof (Design)); + .RegisterAttached("DataContext", typeof (Design)); - public static void SetDataContext(TopLevel topLevel, object value) + public static void SetDataContext(Control control, object value) { - topLevel.SetValue(DataContextProperty, value); + control.SetValue(DataContextProperty, value); } - public static object GetDataContext(TopLevel topLevel) + public static object GetDataContext(Control control) { - return topLevel.GetValue(DataContextProperty); + return control.GetValue(DataContextProperty); } static Design() @@ -62,11 +62,11 @@ namespace Perspex if(!IsDesignMode) return; if (args.Property == WidthProperty) - ((TopLevel) args.Sender).Width = (double) args.NewValue; + ((Control) args.Sender).Width = (double) args.NewValue; if (args.Property == HeightProperty) - ((TopLevel)args.Sender).Height = (double)args.NewValue; + ((Control)args.Sender).Height = (double)args.NewValue; if (args.Property == DataContextProperty) - ((TopLevel) args.Sender).DataContext = args.NewValue; + ((Control) args.Sender).DataContext = args.NewValue; } } }