Browse Source

Don't override UserControl.StyleKey.

Instead of pinning `UserControl.StyleKey` at `typeof(UserControl)`, make the `UserControl` default template selector `:is(UserControl)`. This will allow controls derived from `UserControl` to be more easily styled.
pull/2374/head
Steven Kirk 7 years ago
parent
commit
f9b263997f
  1. 3
      src/Avalonia.Controls/UserControl.cs
  2. 2
      src/Avalonia.Themes.Default/UserControl.xaml

3
src/Avalonia.Controls/UserControl.cs

@ -27,9 +27,6 @@ namespace Avalonia.Controls
remove { _nameScope.Unregistered -= value; }
}
/// <inheritdoc/>
Type IStyleable.StyleKey => typeof(UserControl);
/// <inheritdoc/>
void INameScope.Register(string name, object element)
{

2
src/Avalonia.Themes.Default/UserControl.xaml

@ -1,4 +1,4 @@
<Style xmlns="https://github.com/avaloniaui" Selector="UserControl">
<Style xmlns="https://github.com/avaloniaui" Selector=":is(UserControl)">
<Setter Property="Template">
<ControlTemplate>
<ContentPresenter Name="PART_ContentPresenter"

Loading…
Cancel
Save