Browse Source

Add DesignStyle property which allows style to be assigned only at design time, similar to WPF.

pull/6617/head
Greig Lambourne 5 years ago
parent
commit
3984acb69f
  1. 15
      src/Avalonia.Controls/Design.cs

15
src/Avalonia.Controls/Design.cs

@ -60,6 +60,19 @@ namespace Avalonia.Controls
return target.GetValue(PreviewWithProperty);
}
public static readonly AttachedProperty<Style> DesignStyleProperty = AvaloniaProperty
.RegisterAttached<Control, Style>("DesignStyle", typeof(Design));
public static void SetDesignStyle(Control control, Style value)
{
control.SetValue(DesignStyleProperty, value);
}
public static Style GetDesignStyle(Control control)
{
return control.GetValue(DesignStyleProperty);
}
public static void ApplyDesignModeProperties(Control target, Control source)
{
if (source.IsSet(WidthProperty))
@ -68,6 +81,8 @@ namespace Avalonia.Controls
target.Height = source.GetValue(HeightProperty);
if (source.IsSet(DataContextProperty))
target.DataContext = source.GetValue(DataContextProperty);
if (source.IsSet(DesignStyleProperty))
target.Styles.Add(source.GetValue(DesignStyleProperty));
}
}
}

Loading…
Cancel
Save