Skip to content

Commit

Permalink
Merge pull request #6617 from SilentCoyote/DesignStyle
Browse files Browse the repository at this point in the history
Add DesignStyle property
  • Loading branch information
kekekeks committed Sep 20, 2021
2 parents 7884b4b + 5c31f91 commit ee69220
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Avalonia.Controls/Design.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ public static Control GetPreviewWith(AvaloniaObject target)
return target.GetValue(PreviewWithProperty);
}

public static readonly AttachedProperty<IStyle> DesignStyleProperty = AvaloniaProperty
.RegisterAttached<Control, IStyle>("DesignStyle", typeof(Design));

public static void SetDesignStyle(Control control, IStyle value)
{
control.SetValue(DesignStyleProperty, value);
}

public static IStyle GetDesignStyle(Control control)
{
return control.GetValue(DesignStyleProperty);
}

public static void ApplyDesignModeProperties(Control target, Control source)
{
if (source.IsSet(WidthProperty))
Expand All @@ -68,6 +81,8 @@ public static void ApplyDesignModeProperties(Control target, Control source)
target.Height = source.GetValue(HeightProperty);
if (source.IsSet(DataContextProperty))
target.DataContext = source.GetValue(DataContextProperty);
if (source.IsSet(DesignStyleProperty))
target.Styles.Add(source.GetValue(DesignStyleProperty));
}
}
}

0 comments on commit ee69220

Please sign in to comment.