diff --git a/src/Avalonia.Base/StyledElement.cs b/src/Avalonia.Base/StyledElement.cs
index 3270fe4614..196fa850d6 100644
--- a/src/Avalonia.Base/StyledElement.cs
+++ b/src/Avalonia.Base/StyledElement.cs
@@ -30,10 +30,12 @@ namespace Avalonia
ILogical,
IThemeVariantHost,
IStyleHost,
- IStyleable,
ISetLogicalParent,
ISetInheritanceParent,
- ISupportInitialize
+ ISupportInitialize,
+#pragma warning disable CS0618 // Type or member is obsolete
+ IStyleable
+#pragma warning restore CS0618 // Type or member is obsolete
{
///
/// Defines the property.
@@ -217,6 +219,18 @@ namespace Avalonia
///
public Styles Styles => _styles ??= new Styles(this);
+ ///
+ /// Gets the type by which the element is styled.
+ ///
+ ///
+ /// Usually controls are styled by their own type, but there are instances where you want
+ /// an element to be styled by its base type, e.g. creating SpecialButton that
+ /// derives from Button and adds extra functionality but is still styled as a regular
+ /// Button. To change the style for a control class, override the
+ /// property
+ ///
+ public Type StyleKey => StyleKeyOverride;
+
///
/// Gets or sets the styled element's resource dictionary.
///
@@ -278,6 +292,18 @@ namespace Avalonia
///
protected IPseudoClasses PseudoClasses => Classes;
+ ///
+ /// Gets the type by which the element is styled.
+ ///
+ ///
+ /// Usually controls are styled by their own type, but there are instances where you want
+ /// an element to be styled by its base type, e.g. creating SpecialButton that
+ /// derives from Button and adds extra functionality but is still styled as a regular
+ /// Button. Override this property to change the style for a control class, returning the
+ /// type that you wish the elements to be styled as.
+ ///
+ protected virtual Type StyleKeyOverride => GetType();
+
///
/// Gets a value indicating whether the element is attached to a rooted logical tree.
///
@@ -309,24 +335,12 @@ namespace Avalonia
///
IAvaloniaReadOnlyList IStyleable.Classes => Classes;
- ///
- /// Gets the type by which the styled element is styled.
- ///
- ///
- /// Usually controls are styled by their own type, but there are instances where you want
- /// a styled element to be styled by its base type, e.g. creating SpecialButton that
- /// derives from Button and adds extra functionality but is still styled as a regular
- /// Button.
- ///
- Type IStyleable.StyleKey => GetType();
-
///
bool IStyleHost.IsStylesInitialized => _styles != null;
///
IStyleHost? IStyleHost.StylingParent => (IStyleHost?)InheritanceParent;
-
///
public virtual void BeginInit()
{
@@ -669,7 +683,7 @@ namespace Avalonia
// If the Theme property is not set, try to find a ControlTheme resource with our StyleKey.
if (_implicitTheme is null)
{
- var key = ((IStyleable)this).StyleKey;
+ var key = GetStyleKey(this);
if (this.TryFindResource(key, out var value) && value is ControlTheme t)
_implicitTheme = t;
@@ -700,6 +714,22 @@ namespace Avalonia
}
}
+ ///
+ /// Internal getter for so that we only need to suppress the obsolete
+ /// warning in one place.
+ ///
+ /// The element
+ ///
+ /// is obsolete and will be removed in a future version, but for backwards
+ /// compatibility we need to support code which overrides .
+ ///
+ internal static Type GetStyleKey(StyledElement e)
+ {
+#pragma warning disable CS0618 // Type or member is obsolete
+ return ((IStyleable)e).StyleKey;
+#pragma warning restore CS0618 // Type or member is obsolete
+ }
+
private static void DataContextNotifying(AvaloniaObject o, bool updateStarted)
{
if (o is StyledElement element)
diff --git a/src/Avalonia.Base/Styling/ControlTheme.cs b/src/Avalonia.Base/Styling/ControlTheme.cs
index 22c8f61577..75a3beb907 100644
--- a/src/Avalonia.Base/Styling/ControlTheme.cs
+++ b/src/Avalonia.Base/Styling/ControlTheme.cs
@@ -46,7 +46,7 @@ namespace Avalonia.Styling
if (TargetType is null)
throw new InvalidOperationException("ControlTheme has no TargetType.");
- if (HasSettersOrAnimations && TargetType.IsAssignableFrom(((IStyleable)target).StyleKey))
+ if (HasSettersOrAnimations && TargetType.IsAssignableFrom(StyledElement.GetStyleKey(target)))
{
Attach(target, null, type);
return SelectorMatchResult.AlwaysThisType;
diff --git a/src/Avalonia.Base/Styling/DescendentSelector.cs b/src/Avalonia.Base/Styling/DescendentSelector.cs
index 77ae0f2877..20874a6877 100644
--- a/src/Avalonia.Base/Styling/DescendentSelector.cs
+++ b/src/Avalonia.Base/Styling/DescendentSelector.cs
@@ -44,9 +44,9 @@ namespace Avalonia.Styling
{
c = c.LogicalParent;
- if (c is IStyleable)
+ if (c is StyledElement s)
{
- var match = _parent.Match((StyledElement)c, parent, subscribe);
+ var match = _parent.Match(s, parent, subscribe);
if (match.Result == SelectorMatchResult.Sometimes)
{
diff --git a/src/Avalonia.Base/Styling/IStyleable.cs b/src/Avalonia.Base/Styling/IStyleable.cs
index a6cc2c0f76..0768669905 100644
--- a/src/Avalonia.Base/Styling/IStyleable.cs
+++ b/src/Avalonia.Base/Styling/IStyleable.cs
@@ -1,13 +1,12 @@
using System;
using Avalonia.Collections;
-using Avalonia.Metadata;
namespace Avalonia.Styling
{
///
/// Interface for styleable elements.
///
- [NotClientImplementable]
+ [Obsolete("This interface may be removed in 12.0. Use StyledElement, or override StyledElement.StyleKeyOverride to override the StyleKey for a class.")]
public interface IStyleable : INamed
{
///
@@ -18,6 +17,7 @@ namespace Avalonia.Styling
///
/// Gets the type by which the control is styled.
///
+ [Obsolete("Override StyledElement.StyleKeyOverride instead.")]
Type StyleKey { get; }
///
diff --git a/src/Avalonia.Base/Styling/NestingSelector.cs b/src/Avalonia.Base/Styling/NestingSelector.cs
index 980bf12907..deb688ca4d 100644
--- a/src/Avalonia.Base/Styling/NestingSelector.cs
+++ b/src/Avalonia.Base/Styling/NestingSelector.cs
@@ -23,7 +23,7 @@ namespace Avalonia.Styling
{
if (theme.TargetType is null)
throw new InvalidOperationException("ControlTheme has no TargetType.");
- return theme.TargetType.IsAssignableFrom(((IStyleable)control).StyleKey) ?
+ return theme.TargetType.IsAssignableFrom(StyledElement.GetStyleKey(control)) ?
SelectorMatch.AlwaysThisType :
SelectorMatch.NeverThisType;
}
diff --git a/src/Avalonia.Base/Styling/Selectors.cs b/src/Avalonia.Base/Styling/Selectors.cs
index 476d86cd11..d7406f2164 100644
--- a/src/Avalonia.Base/Styling/Selectors.cs
+++ b/src/Avalonia.Base/Styling/Selectors.cs
@@ -76,7 +76,7 @@ namespace Avalonia.Styling
/// The type.
/// The previous selector.
/// The selector.
- public static Selector Is(this Selector? previous) where T : IStyleable
+ public static Selector Is(this Selector? previous) where T : StyledElement
{
return previous.Is(typeof(T));
}
@@ -171,7 +171,7 @@ namespace Avalonia.Styling
/// The type.
/// The previous selector.
/// The selector.
- public static Selector OfType(this Selector? previous) where T : IStyleable
+ public static Selector OfType(this Selector? previous) where T : StyledElement
{
return previous.OfType(typeof(T));
}
diff --git a/src/Avalonia.Base/Styling/TypeNameAndClassSelector.cs b/src/Avalonia.Base/Styling/TypeNameAndClassSelector.cs
index a10b3eb3ea..2bd05242f5 100644
--- a/src/Avalonia.Base/Styling/TypeNameAndClassSelector.cs
+++ b/src/Avalonia.Base/Styling/TypeNameAndClassSelector.cs
@@ -93,7 +93,7 @@ namespace Avalonia.Styling
{
if (TargetType != null)
{
- var controlType = ((IStyleable)control).StyleKey ?? control.GetType();
+ var controlType = StyledElement.GetStyleKey(control) ?? control.GetType();
if (IsConcreteType)
{
diff --git a/src/Avalonia.Controls/Embedding/EmbeddableControlRoot.cs b/src/Avalonia.Controls/Embedding/EmbeddableControlRoot.cs
index b79fef55b9..7a0ab36050 100644
--- a/src/Avalonia.Controls/Embedding/EmbeddableControlRoot.cs
+++ b/src/Avalonia.Controls/Embedding/EmbeddableControlRoot.cs
@@ -7,7 +7,7 @@ using Avalonia.Styling;
namespace Avalonia.Controls.Embedding
{
- public class EmbeddableControlRoot : TopLevel, IStyleable, IFocusScope, IDisposable
+ public class EmbeddableControlRoot : TopLevel, IFocusScope, IDisposable
{
public EmbeddableControlRoot(ITopLevelImpl impl) : base(impl)
{
@@ -46,7 +46,7 @@ namespace Avalonia.Controls.Embedding
return rv;
}
- Type IStyleable.StyleKey => typeof(EmbeddableControlRoot);
+ protected override Type StyleKeyOverride => typeof(EmbeddableControlRoot);
public void Dispose() => PlatformImpl?.Dispose();
}
}
diff --git a/src/Avalonia.Controls/Embedding/Offscreen/OffscreenTopLevel.cs b/src/Avalonia.Controls/Embedding/Offscreen/OffscreenTopLevel.cs
index b037dd9901..a87e36d00d 100644
--- a/src/Avalonia.Controls/Embedding/Offscreen/OffscreenTopLevel.cs
+++ b/src/Avalonia.Controls/Embedding/Offscreen/OffscreenTopLevel.cs
@@ -4,7 +4,7 @@ using Avalonia.Styling;
namespace Avalonia.Controls.Embedding.Offscreen
{
- class OffscreenTopLevel : TopLevel, IStyleable
+ class OffscreenTopLevel : TopLevel
{
public OffscreenTopLevelImplBase Impl { get; }
@@ -31,7 +31,7 @@ namespace Avalonia.Controls.Embedding.Offscreen
}
}
- Type IStyleable.StyleKey => typeof(EmbeddableControlRoot);
+ protected override Type StyleKeyOverride => typeof(EmbeddableControlRoot);
public void Dispose()
{
PlatformImpl?.Dispose();
diff --git a/src/Avalonia.Controls/ItemsControl.cs b/src/Avalonia.Controls/ItemsControl.cs
index 064716fa9b..1613bda45b 100644
--- a/src/Avalonia.Controls/ItemsControl.cs
+++ b/src/Avalonia.Controls/ItemsControl.cs
@@ -712,7 +712,7 @@ namespace Avalonia.Controls
if (itemContainerTheme is not null &&
!container.IsSet(ThemeProperty) &&
- ((IStyleable)container).StyleKey == itemContainerTheme.TargetType)
+ StyledElement.GetStyleKey(container) == itemContainerTheme.TargetType)
{
container.Theme = itemContainerTheme;
}
diff --git a/src/Avalonia.Controls/MaskedTextBox.cs b/src/Avalonia.Controls/MaskedTextBox.cs
index f54e8b19db..4800b7b1e4 100644
--- a/src/Avalonia.Controls/MaskedTextBox.cs
+++ b/src/Avalonia.Controls/MaskedTextBox.cs
@@ -10,7 +10,7 @@ using Avalonia.Styling;
namespace Avalonia.Controls
{
- public class MaskedTextBox : TextBox, IStyleable
+ public class MaskedTextBox : TextBox
{
public static readonly StyledProperty AsciiOnlyProperty =
AvaloniaProperty.Register(nameof(AsciiOnly));
@@ -183,7 +183,7 @@ namespace Avalonia.Controls
set => SetValue(ResetOnSpaceProperty, value);
}
- Type IStyleable.StyleKey => typeof(TextBox);
+ protected override Type StyleKeyOverride => typeof(TextBox);
///
protected override void OnGotFocus(GotFocusEventArgs e)
diff --git a/src/Avalonia.Controls/SplitButton/ToggleSplitButton.cs b/src/Avalonia.Controls/SplitButton/ToggleSplitButton.cs
index 509b58833f..ff8bd5dc0b 100644
--- a/src/Avalonia.Controls/SplitButton/ToggleSplitButton.cs
+++ b/src/Avalonia.Controls/SplitButton/ToggleSplitButton.cs
@@ -13,7 +13,7 @@ namespace Avalonia.Controls
/// the secondary part opens a flyout.
///
[PseudoClasses(pcChecked)]
- public class ToggleSplitButton : SplitButton, IStyleable
+ public class ToggleSplitButton : SplitButton
{
///
/// Raised when the property value changes.
@@ -63,7 +63,7 @@ namespace Avalonia.Controls
/// Both and share
/// the same exact default style.
///
- Type IStyleable.StyleKey => typeof(SplitButton);
+ protected override Type StyleKeyOverride => typeof(SplitButton);
///
/// Toggles the property between true and false.
diff --git a/src/Avalonia.Controls/UserControl.cs b/src/Avalonia.Controls/UserControl.cs
index e9339d5f4b..40c312be42 100644
--- a/src/Avalonia.Controls/UserControl.cs
+++ b/src/Avalonia.Controls/UserControl.cs
@@ -5,7 +5,7 @@ namespace Avalonia.Controls
///
/// Provides the base class for defining a new control that encapsulates related existing controls and provides its own logic.
///
- public class UserControl : ContentControl, IStyleable
+ public class UserControl : ContentControl
{
}
diff --git a/src/Avalonia.Controls/Window.cs b/src/Avalonia.Controls/Window.cs
index 66cce89b9d..3f04350995 100644
--- a/src/Avalonia.Controls/Window.cs
+++ b/src/Avalonia.Controls/Window.cs
@@ -65,7 +65,7 @@ namespace Avalonia.Controls
///
/// A top-level window.
///
- public class Window : WindowBase, IStyleable, IFocusScope, ILayoutRoot
+ public class Window : WindowBase, IFocusScope, ILayoutRoot
{
private readonly List<(Window child, bool isDialog)> _children = new List<(Window, bool)>();
private bool _isExtendedIntoWindowDecorations;
@@ -420,7 +420,7 @@ namespace Avalonia.Controls
public void BeginResizeDrag(WindowEdge edge, PointerPressedEventArgs e) => PlatformImpl?.BeginResizeDrag(edge, e);
///
- Type IStyleable.StyleKey => typeof(Window);
+ protected override Type StyleKeyOverride => typeof(Window);
///
/// Fired before a window is closed.
diff --git a/src/Avalonia.Diagnostics/Diagnostics/Controls/CommitTextBox.cs b/src/Avalonia.Diagnostics/Diagnostics/Controls/CommitTextBox.cs
index 7870febd0a..d724318641 100644
--- a/src/Avalonia.Diagnostics/Diagnostics/Controls/CommitTextBox.cs
+++ b/src/Avalonia.Diagnostics/Diagnostics/Controls/CommitTextBox.cs
@@ -7,9 +7,9 @@ using Avalonia.Styling;
namespace Avalonia.Diagnostics.Controls
{
//TODO: UpdateSourceTrigger & Binding.ValidationRules could help removing the need for this control.
- internal sealed class CommitTextBox : TextBox, IStyleable
+ internal sealed class CommitTextBox : TextBox
{
- Type IStyleable.StyleKey => typeof(TextBox);
+ protected override Type StyleKeyOverride => typeof(TextBox);
///
/// Defines the property.
diff --git a/src/Avalonia.Diagnostics/Diagnostics/Controls/FilterTextBox.cs b/src/Avalonia.Diagnostics/Diagnostics/Controls/FilterTextBox.cs
index 1e5674cc21..c703c73549 100644
--- a/src/Avalonia.Diagnostics/Diagnostics/Controls/FilterTextBox.cs
+++ b/src/Avalonia.Diagnostics/Diagnostics/Controls/FilterTextBox.cs
@@ -5,7 +5,7 @@ using Avalonia.Styling;
namespace Avalonia.Diagnostics.Controls
{
- internal class FilterTextBox : TextBox, IStyleable
+ internal class FilterTextBox : TextBox
{
public static readonly StyledProperty UseRegexFilterProperty =
AvaloniaProperty.Register(nameof(UseRegexFilter),
@@ -42,6 +42,6 @@ namespace Avalonia.Diagnostics.Controls
set => SetValue(UseWholeWordFilterProperty, value);
}
- Type IStyleable.StyleKey => typeof(TextBox);
+ protected override Type StyleKeyOverride => typeof(TextBox);
}
}
diff --git a/src/Avalonia.Diagnostics/Diagnostics/ViewModels/TreePageViewModel.cs b/src/Avalonia.Diagnostics/Diagnostics/ViewModels/TreePageViewModel.cs
index 4e8b4c66a2..67dbfed92b 100644
--- a/src/Avalonia.Diagnostics/Diagnostics/ViewModels/TreePageViewModel.cs
+++ b/src/Avalonia.Diagnostics/Diagnostics/ViewModels/TreePageViewModel.cs
@@ -208,7 +208,7 @@ namespace Avalonia.Diagnostics.ViewModels
var classes = string.Concat(visual.Classes
.Where(c => !c.StartsWith(":"))
.Select(c => '.' + c));
- var typeName = ((IStyleable)visual).StyleKey.Name;
+ var typeName = StyledElement.GetStyleKey(visual);
return $"{typeName}{name}{classes}";
}
diff --git a/src/Avalonia.Diagnostics/Diagnostics/ViewModels/VisualTreeNode.cs b/src/Avalonia.Diagnostics/Diagnostics/ViewModels/VisualTreeNode.cs
index c3ebb1beaf..8dbcd606b0 100644
--- a/src/Avalonia.Diagnostics/Diagnostics/ViewModels/VisualTreeNode.cs
+++ b/src/Avalonia.Diagnostics/Diagnostics/ViewModels/VisualTreeNode.cs
@@ -23,7 +23,7 @@ namespace Avalonia.Diagnostics.ViewModels
_ => TreeNodeCollection.Empty
};
- if (Visual is IStyleable styleable)
+ if (Visual is StyledElement styleable)
IsInTemplate = styleable.TemplatedParent != null;
}
diff --git a/src/Avalonia.ReactiveUI/RoutedViewHost.cs b/src/Avalonia.ReactiveUI/RoutedViewHost.cs
index 2d848d4cd7..701b0d0f46 100644
--- a/src/Avalonia.ReactiveUI/RoutedViewHost.cs
+++ b/src/Avalonia.ReactiveUI/RoutedViewHost.cs
@@ -50,7 +50,7 @@ namespace Avalonia.ReactiveUI
/// ReactiveUI routing documentation website for more info.
///
///
- public class RoutedViewHost : TransitioningContentControl, IActivatableView, IEnableLogger, IStyleable
+ public class RoutedViewHost : TransitioningContentControl, IActivatableView, IEnableLogger
{
///
/// for the property.
@@ -126,7 +126,7 @@ namespace Avalonia.ReactiveUI
///
public IViewLocator? ViewLocator { get; set; }
- Type IStyleable.StyleKey => typeof(TransitioningContentControl);
+ protected override Type StyleKeyOverride => typeof(TransitioningContentControl);
///
/// Invoked when ReactiveUI router navigates to a view model.
diff --git a/src/Avalonia.ReactiveUI/ViewModelViewHost.cs b/src/Avalonia.ReactiveUI/ViewModelViewHost.cs
index dc45758046..3e7ed42662 100644
--- a/src/Avalonia.ReactiveUI/ViewModelViewHost.cs
+++ b/src/Avalonia.ReactiveUI/ViewModelViewHost.cs
@@ -13,7 +13,7 @@ namespace Avalonia.ReactiveUI
/// the ViewModel property and display it. This control is very useful
/// inside a DataTemplate to display the View associated with a ViewModel.
///
- public class ViewModelViewHost : TransitioningContentControl, IViewFor, IEnableLogger, IStyleable
+ public class ViewModelViewHost : TransitioningContentControl, IViewFor, IEnableLogger
{
///
/// for the property.
@@ -78,7 +78,7 @@ namespace Avalonia.ReactiveUI
///
public IViewLocator? ViewLocator { get; set; }
- Type IStyleable.StyleKey => typeof(TransitioningContentControl);
+ protected override Type StyleKeyOverride => typeof(TransitioningContentControl);
///
/// Invoked when ReactiveUI router navigates to a view model.
diff --git a/src/Windows/Avalonia.Win32/TrayIconImpl.cs b/src/Windows/Avalonia.Win32/TrayIconImpl.cs
index d541e6b436..5069add9fd 100644
--- a/src/Windows/Avalonia.Win32/TrayIconImpl.cs
+++ b/src/Windows/Avalonia.Win32/TrayIconImpl.cs
@@ -170,9 +170,9 @@ namespace Avalonia.Win32
WM_TRAYMOUSE = WindowsMessage.WM_USER + 1024,
}
- private class TrayIconMenuFlyoutPresenter : MenuFlyoutPresenter, IStyleable
+ private class TrayIconMenuFlyoutPresenter : MenuFlyoutPresenter
{
- Type IStyleable.StyleKey => typeof(MenuFlyoutPresenter);
+ protected override Type StyleKeyOverride => typeof(MenuFlyoutPresenter);
public override void Close()
{
diff --git a/tests/Avalonia.Controls.UnitTests/ItemsControlTests.cs b/tests/Avalonia.Controls.UnitTests/ItemsControlTests.cs
index 3d4852c4ff..86249c66ff 100644
--- a/tests/Avalonia.Controls.UnitTests/ItemsControlTests.cs
+++ b/tests/Avalonia.Controls.UnitTests/ItemsControlTests.cs
@@ -1031,9 +1031,9 @@ namespace Avalonia.Controls.UnitTests
textShaperImpl: new HeadlessTextShaperStub()));
}
- private class ItemsControlWithContainer : ItemsControl, IStyleable
+ private class ItemsControlWithContainer : ItemsControl
{
- Type IStyleable.StyleKey => typeof(ItemsControl);
+ protected override Type StyleKeyOverride => typeof(ItemsControl);
protected internal override Control CreateContainerForItemOverride(object? item, int index, object? recycleKey)
{
@@ -1046,9 +1046,9 @@ namespace Avalonia.Controls.UnitTests
}
}
- private class ContainerControl : ContentControl, IStyleable
+ private class ContainerControl : ContentControl
{
- Type IStyleable.StyleKey => typeof(ContentControl);
+ protected override Type StyleKeyOverride => typeof(ContentControl);
}
private record Item(string Caption, string? Value = null);
diff --git a/tests/Avalonia.Controls.UnitTests/Primitives/SelectingItemsControlTests_Multiple.cs b/tests/Avalonia.Controls.UnitTests/Primitives/SelectingItemsControlTests_Multiple.cs
index 78ac6bb3e2..a4181fa8e8 100644
--- a/tests/Avalonia.Controls.UnitTests/Primitives/SelectingItemsControlTests_Multiple.cs
+++ b/tests/Avalonia.Controls.UnitTests/Primitives/SelectingItemsControlTests_Multiple.cs
@@ -1392,9 +1392,9 @@ namespace Avalonia.Controls.UnitTests.Primitives
public void Toggle(int index) => UpdateSelection(index, true, false, true);
}
- private class TestSelectorWithContainers : TestSelector, IStyleable
+ private class TestSelectorWithContainers : TestSelector
{
- Type IStyleable.StyleKey => typeof(TestSelector);
+ protected override Type StyleKeyOverride => typeof(TestSelector);
protected internal override Control CreateContainerForItemOverride(object? item, int index, object? recycleKey)
{
diff --git a/tests/Avalonia.Controls.UnitTests/TabControlTests.cs b/tests/Avalonia.Controls.UnitTests/TabControlTests.cs
index 15ba871e8c..0d3eb80ae7 100644
--- a/tests/Avalonia.Controls.UnitTests/TabControlTests.cs
+++ b/tests/Avalonia.Controls.UnitTests/TabControlTests.cs
@@ -603,9 +603,9 @@ namespace Avalonia.Controls.UnitTests
public string Value { get; }
}
- private class TestTabControl : TabControl, IStyleable
+ private class TestTabControl : TabControl
{
- Type IStyleable.StyleKey => typeof(TabControl);
+ protected override Type StyleKeyOverride => typeof(TabControl);
public new ISelectionModel Selection => base.Selection;
}
}
diff --git a/tests/Avalonia.Markup.Xaml.UnitTests/Converters/AvaloniaPropertyConverterTest.cs b/tests/Avalonia.Markup.Xaml.UnitTests/Converters/AvaloniaPropertyConverterTest.cs
index d4d188f584..241ebc2d38 100644
--- a/tests/Avalonia.Markup.Xaml.UnitTests/Converters/AvaloniaPropertyConverterTest.cs
+++ b/tests/Avalonia.Markup.Xaml.UnitTests/Converters/AvaloniaPropertyConverterTest.cs
@@ -1,12 +1,10 @@
using System;
-using Moq;
-using Avalonia.Collections;
+using System.ComponentModel;
using Avalonia.Markup.Xaml.Converters;
+using Avalonia.Markup.Xaml.XamlIl.Runtime;
using Avalonia.Styling;
+using Moq;
using Xunit;
-using System.ComponentModel;
-using Avalonia.Markup.Xaml.XamlIl.Runtime;
-using System.Collections.Generic;
namespace Avalonia.Markup.Xaml.UnitTests.Converters
{
@@ -112,61 +110,17 @@ namespace Avalonia.Markup.Xaml.UnitTests.Converters
return tdMock.Object;
}
- private class Class1 : AvaloniaObject, IStyleable
+ private class Class1 : StyledElement
{
public static readonly StyledProperty FooProperty =
AvaloniaProperty.Register("Foo");
- public IAvaloniaReadOnlyList Classes
- {
- get { throw new NotImplementedException(); }
- }
-
- public string Name
- {
- get { throw new NotImplementedException(); }
- }
-
- public Type StyleKey
- {
- get { throw new NotImplementedException(); }
- }
-
- public AvaloniaObject TemplatedParent
- {
- get { throw new NotImplementedException(); }
- }
-
- public ControlTheme GetEffectiveTheme()
- {
- throw new NotImplementedException();
- }
-
public ThemeVariant ThemeVariant
{
get { throw new NotImplementedException(); }
}
- public event EventHandler ThemeVariantChanged;
-
- public void DetachStyles()
- {
- throw new NotImplementedException();
- }
- public void DetachStyles(IReadOnlyList styles)
- {
- throw new NotImplementedException();
- }
-
- public void InvalidateStyles()
- {
- throw new NotImplementedException();
- }
-
- public void StyleApplied(IStyleInstance instance)
- {
- throw new NotImplementedException();
- }
+ public event EventHandler ThemeVariantChanged;
}
private class AttachedOwner