Home > Software design >  DefaultStyleKeyProperty.OverrideMetadata in Avalonia UI?
DefaultStyleKeyProperty.OverrideMetadata in Avalonia UI?

Time:11-16

In WPF, when deriving a control from a base control, you add this in the constructor.

DefaultStyleKeyProperty.OverrideMetadata(typeof(MediaPlayer), new StyledPropertyMetadata(typeof(MediaPlayer)));

How do you convert this to Avalonia UI?

CodePudding user response:

Implement IStyleable interface and set StyleKey to your type.

public class MyGrid : Grid, IStyleable
{
    Type IStyleable.StyleKey => typeof(MyGrid);
}
  • Related