简体   繁体   中英

DefaultStyleKeyProperty.OverrideMetadata in Avalonia UI?

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?

Implement IStyleable interface and set StyleKey to your type.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM