From 1bbc155303dbcdaffec3d8f36356e2467ba9fd99 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 29 May 2018 15:35:08 -0500 Subject: [PATCH] Use a concrete type for the host type to avoid #959. --- src/Avalonia.Controls/Design.cs | 6 +++--- src/Avalonia.DesignerSupport/DesignWindowLoader.cs | 3 +-- src/Avalonia.Styling/Styling/IStyle.cs | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Avalonia.Controls/Design.cs b/src/Avalonia.Controls/Design.cs index 3a67e554ac..894240a09f 100644 --- a/src/Avalonia.Controls/Design.cs +++ b/src/Avalonia.Controls/Design.cs @@ -48,14 +48,14 @@ namespace Avalonia.Controls } public static readonly AttachedProperty PreviewWithProperty = AvaloniaProperty - .RegisterAttached("PreviewWith", typeof (Design)); + .RegisterAttached("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); } diff --git a/src/Avalonia.DesignerSupport/DesignWindowLoader.cs b/src/Avalonia.DesignerSupport/DesignWindowLoader.cs index d1958ac9bf..6dca479d38 100644 --- a/src/Avalonia.DesignerSupport/DesignWindowLoader.cs +++ b/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