How can I only include styles for a specific control?

Fundamentals for Avalonia Forum

Posted 6 months ago by Magnus Lindhe
Avatar

Is it possible to include styles only for specific controls? 

Comments (3)

Posted 6 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Magnus,

Can you provide some more information on your question, such as which controls you only want styles for and why?  Thank you, that will help us better understand the context of the question.

If you mean that you wish to prevent us from theming native Avalonia controls, you can follow the directions in this documentation topic.


Actipro Software Support

Posted 6 months ago by Magnus Lindhe
Avatar

Consider a scenario where FluentAvalonia (or any other theme) and ModernTheme are used together. ModernTheme is added first and FluentAvalonia second. This makes FluentAvalonia override all the default native control themes. I can use all the fundamental controls from ModernTheme with the correct style but what if I'd like to style a specific native Button using a the control theme from ModernTheme. How would I achieve that?

Answer - Posted 6 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

If you wanted to include a ControlTheme for a specific control, like a Button, you could add a ControlTheme whose key is the control type, targets the same type, and is BasedOn one of our predefined ControlThemes.  Our "actipro:ControlTheme" markup extension helps find those.

For example:

<ControlTheme x:Key="{x:Type Button}" TargetType="Button"
  BasedOn="{actipro:ControlTheme ButtonOutline}">


Actipro Software Support

Add Comment

Please log in to a validated account to post comments.