Browse Source

Use a concrete type for the host type to avoid #959.

pull/1629/head
Jeremy Koritzinsky 8 years ago
parent
commit
1bbc155303
  1. 6
      src/Avalonia.Controls/Design.cs
  2. 3
      src/Avalonia.DesignerSupport/DesignWindowLoader.cs
  3. 2
      src/Avalonia.Styling/Styling/IStyle.cs

6
src/Avalonia.Controls/Design.cs

@ -48,14 +48,14 @@ namespace Avalonia.Controls
}
public static readonly AttachedProperty<Control> PreviewWithProperty = AvaloniaProperty
.RegisterAttached<IStyle, Control>("PreviewWith", typeof (Design));
.RegisterAttached<Style, Control>("PreviewWith", typeof (Design));
public static void SetPreviewWith(IStyle target, Control control)
public static void SetPreviewWith(Style target, Control control)
{
target.SetValue(PreviewWithProperty, control);
}
public static Control GetPreviewWith(IStyle target)
public static Control GetPreviewWith(Style target)
{
return target.GetValue(PreviewWithProperty);
}

3
src/Avalonia.DesignerSupport/DesignWindowLoader.cs

@ -36,8 +36,7 @@ namespace Avalonia.DesignerSupport
var styles = loaded as Styles;
if (styles != null)
{
var substitute = Design.GetPreviewWith(styles) ??
styles.Select(Design.GetPreviewWith).FirstOrDefault(s => s != null);
var substitute = styles.OfType<Style>().Select(Design.GetPreviewWith).FirstOrDefault(s => s != null);
if (substitute != null)
{
substitute.Styles.AddRange(styles);

2
src/Avalonia.Styling/Styling/IStyle.cs

@ -8,7 +8,7 @@ namespace Avalonia.Styling
/// <summary>
/// Defines the interface for styles.
/// </summary>
public interface IStyle : IAvaloniaObject, IResourceNode
public interface IStyle : IResourceNode
{
/// <summary>
/// Attaches the style to a control if the style's selector matches.

Loading…
Cancel
Save