How to change button content when clicked in Xaml?

前端 未结 3 528
被撕碎了的回忆
被撕碎了的回忆 2021-01-18 05:49

I have buttoncontent named Hold button. Once when I clicked button the button content should change to Resume, again if pressed resume button means Hold should be visible.

3条回答
  •  爱一瞬间的悲伤
    2021-01-18 06:02

    You can try something like this in the button's Click event:

    private void holdResumeButton_Click(object sender, RoutedEventArgs e)
    {
            if ((string)holdResumeButton.Content == "Hold")
                holdResumeButton.Content = "Resume";
    
            else
                holdResumeButton.Content = "Hold";
    
    }
    

    XAML:

提交回复
热议问题