0
votes

I want to involve a feature in a Xamarin Forms app. This feature should allow a colour to be displayed until the user clicks the screen/ a button, and records the time taken to do so (almost like a reaction time thing.) This should repeat for different colours, with a pause between each of a white screen.

I currently have the main page in MainPage.Xaml, which gives the user the option to click Play Game, taking them to PlayGame.Xaml and PlayGame.Xaml.Cs

enter image description here

I have experience using C sharp, but have never wrote in Xaml before. I am mainly struggling with getting a instructions from the PlayGame.Xaml.Cs to PlayGame.Xaml, ie random background colour, and a timer.

What I mean to say is that while I can separately create a screen with a background colour and a button in the xaml page, and also create a random timer in the c sharp page, I don't know how to combine the 2. Any help?

Sorry for poor english, feel free to comment any questions for clarity.

1
You can mark the answer if it solves your problem so that we can help more people with same problem:).nevermore
Done, I think ?user13720211

1 Answers

0
votes

in the code behind (xaml.cs) of a page, you can access the page's properties directly

BackgroundColor = Color.Yellow;

or you can address individual XAML element by using their name property

<Label x:Name="myLabel" ... />

then in the code

myLabel.BackgroundColor = Color.Blue;

this applies to any property, not just BackgroundColor

you can also use databinding to control XAML properties from you model