Skip to content

Add support for design time discoverability of default style key. #1551

Open

Description

@chabiss

Feature request: add support for design time discoverability of default style key.
Goal: VS XAML intellisense to support Copy Style/Template without running app. Mostly for platform controls like Button and 3rd party SDKs like Telerik.
Details: when creating WPF Core Custom Control Library project in VS, the project contains following:
themes/generic.xaml
<ResourceDictionary . . .>
<Style TargetType="{x:Type local:MyControl}">

MyControl.cs
public class MyControl : Control
{
static MyControl()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(MyControl), new FrameworkPropertyMetadata(typeof(MyControl)));
}
}

This is not design time friendly as we cannot find default style key via Roslyn INamedTypeSymbol for MyControl. One way to fix it is to add DefaultStyleKeyAttribute, e.g.
[DefaultStyleKey(typeof(MyControl))]
public class MyControl : Control

Note that VS project and item templates should be updated to DefaultStyleKeyAttribute.

Activity

  1. added
    Enhancement Requested
    on Aug 8, 2019
  2. added this to the 5.0 milestone on Aug 8, 2019
  3. modified the milestones: 5.0.0, 7.0.0 on Aug 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Enhancement Requested

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions