Reputation: 3
I would like to hide a button after it was clicked but I don't know how.
C#
private async void btn1Clicked(object sender, EventArgs e)
{
if (condition)
{
// hide button
}
}
XAML
<Button Clicked="btn1Clicked"/>
Upvotes: 0
Views: 2961
Reputation: 1738
You can do the following
private async void btn1Clicked(object sender, EventArgs e)
{
Button btn = (Button)sender;
if(condition)
{
// hide the button
btn.IsVisible = false;
// or disable the button.
// As Caius Jard said, disappearing buttons sometimes cause confusion.
btn.IsEnabled = false;
}
}
Upvotes: 0