ispiro ispiro - 26 days ago 13
C# Question

Change button color on single target

I have a Xamarin Forms project (Portable) and see that the colors on one target (UWP) aren't that good. I want to change the color of a button on that target only, but I can't find how to do that.

I've looked at the files, but it seems to load the whole

LoadApplication(new TheApp.App());
as a whole.

Answer

use Device to customize properties per platform

myButton.BackgroundColor = Color.Green;

// on Windows only, change color
if (Device.OS == TargetPlatform.Windows) {
  myButton.BackgroundColor = Color.Blue;
}
Comments