question

njsokalski avatar image
0 Votes"
njsokalski asked RobCaplan edited

Default Style for a Custom Control

I have a Custom Control which inherits from GridLayout, and uses an XML Layout with a root of merge. The first line in my Initialize method is:

 Inflate(context, Resource.Layout.CircleButton, this);

However, I cannot find a way to set a style (like having a style="..." in a layout file) to the GridLayout (which is what the root of the control is, since it inherits from GridLayout). What I have been doing as a workaround is just including the style (the one I want to use by default when the Custom Control is created) in the XML when using the control. However, this is very inconvenient, it is just extra xml that will (almost) always be the same. Is there a way to assign a default style to a Custom Control?

dotnet-xamarin
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I cannot find a way to set a style (like having a style="..." in a layout file) to the GridLayout

Hi, njsokalski. What style do you want to add for the GridLayout? And how did you consume the style in the XML now? Could you please post more details about the style and the related code?

0 Votes 0 ·

0 Answers