A Switch  is a view which has events, that means that can trigger actions when a user interacts with it. In this article we will show how to implement an action when someone enables and disables a Switch  view.

  • Let's add a Switch view, set its Visible to Code attribute to true. We will also set the View's Visible in Code property to true.
  • Next, we will go to Code screen and add a switchValueChanged function. We implement it so that when the Switch's state is on, then the View's background color will be white and when it is off, it will be black.
  • We will return to the Design screen, and add the switchValueChanged function to the "Value Changed" event.

Let's run the app to test if it works!

Seems to work just fine!

Did this answer your question?