I've been using Xamarin.Forms for two weeks now and I haven't been able to figure out how to fully control the styling of my app.
First of all, I wanted to define the style (colors and fonts mostly) in my common library, not in OS-specific code. If I want to override this behaviour on a certain platform I'll do it. So I created my own style class (just a static class containing a map of named resources) to hold a set of named colors and fonts and I used them to set the corresponding properties of my Forms visual elements. This worked fine until I tried to create a button like so...
`new Frame
{
Padding = 15,
Content = new Button
{
Text = Localization.Strings.LoginButton,
TextColor = Style.GetColor("mydarkcolorname"),
BackgroundColor = Style.GetColor("mybackgroundcolorname"),
BorderColor = Style.GetColor("myaccentcolorname"),
BorderWidth = 1,
BorderRadius = 5,
Font = Style.GetFont("mybuttonfontname"),
HorizontalOptions = LayoutOptions.Center,
}
}`
This results in a button with the correct coloring when not pressed however the pressed colors aren't affected. They appear to be the colors from the default theme (I'm testing on Android). So Forms lets me set the basic colors but not based on the state of the visual element (pressed, focused, selected).
I searched the API docs for a way to do this, looking for a more detailed style property, more color properties or even just a IsPressed state that I could read and convert to a color but I didn't find anything.
I assumed then that this was currently missing from Forms and that I'd need to set these things from the OS-specific code. So in my Android app I set an appropriate Theme on my Forms activity. This always results in an exception like this one forums.xamarin.com/discussion/18946/no-title-bar-on-android even though my theme doesn't set windowNoTitle, it only sets a few colors and widget styles.
What is the recommended way to fully style/theme a Xamarin.Forms app? I need to be able to control everything.