Hello,
Welcome to our Microsoft Q&A platform!
when it's on startservice is started and when it's off stopservice is started
Switch provides the Toggled which will be raised when the toggle state of the switch is changed. Try to detect the event to check the status to start or stop the service.
//page.xaml
<Switch Toggled="Switch_Toggled"/>
//the switch's toggled event
private void Switch_Toggled(object sender, ToggledEventArgs e)
{
var isToggled = e.Value; //the bool value to which the toggle control was toggled
if (isToggled)
{
//switch is toggled, start the service
}
else
{
//switch isn't toggled, stop the service
}
}
Best Regards,
Jarvan Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.