|
|
|
@ -25,7 +25,7 @@ namespace Perspex |
|
|
|
} |
|
|
|
|
|
|
|
public static readonly PerspexProperty<double> WidthProperty = PerspexProperty |
|
|
|
.RegisterAttached<TopLevel, double>("Width", typeof (Design)); |
|
|
|
.RegisterAttached<TopLevel, double>("Width", typeof(Design)); |
|
|
|
|
|
|
|
public static void SetWidth(TopLevel topLevel, double value) |
|
|
|
{ |
|
|
|
@ -34,13 +34,27 @@ namespace Perspex |
|
|
|
|
|
|
|
public static double GetWidth(TopLevel topLevel) |
|
|
|
{ |
|
|
|
return (double) topLevel.GetValue(WidthProperty); |
|
|
|
return (double)topLevel.GetValue(WidthProperty); |
|
|
|
} |
|
|
|
|
|
|
|
public static readonly PerspexProperty<object> DataContextProperty = PerspexProperty |
|
|
|
.RegisterAttached<TopLevel, object>("DataContext", typeof (Design)); |
|
|
|
|
|
|
|
public static void SetDataContext(TopLevel topLevel, object value) |
|
|
|
{ |
|
|
|
topLevel.SetValue(DataContextProperty, value); |
|
|
|
} |
|
|
|
|
|
|
|
public static object GetDataContext(TopLevel topLevel) |
|
|
|
{ |
|
|
|
return topLevel.GetValue(DataContextProperty); |
|
|
|
} |
|
|
|
|
|
|
|
static Design() |
|
|
|
{ |
|
|
|
WidthProperty.Changed.Subscribe(OnChanged); |
|
|
|
HeightProperty.Changed.Subscribe(OnChanged); |
|
|
|
DataContextProperty.Changed.Subscribe(OnChanged); |
|
|
|
} |
|
|
|
|
|
|
|
static void OnChanged(PerspexPropertyChangedEventArgs args) |
|
|
|
@ -51,6 +65,8 @@ namespace Perspex |
|
|
|
((TopLevel) args.Sender).Width = (double) args.NewValue; |
|
|
|
if (args.Property == HeightProperty) |
|
|
|
((TopLevel)args.Sender).Height = (double)args.NewValue; |
|
|
|
if (args.Property == DataContextProperty) |
|
|
|
((TopLevel) args.Sender).DataContext = args.NewValue; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|