Windows dynamic button icon

I am trying to make a Windows 10 application with a pause / game.

So far I know 3 ways to set a button using

button.context = "some segoe code" - works fine when I initialize it with a button, but in the code to change the context the button appears as a bunch of squares

Button symbolicon - works with good initialization, but doesn’t know how to change the symbolic value outside the button declaration

uri button is the only thing I can find on the Internet about changing a button, but I don’t have any button libraries that go into a Windows phone ...

what are your recommendations, so clicking a button will change the button to either pause or play

+4
source share
1 answer

SymbolIcon /.

XAML:

<Button Click="play_Click">
    <SymbolIcon x:Name="play" Symbol="Play"/>
</Button>

# :

private void play_Click(object sender, RoutedEventArgs e)
{
    if (play.Symbol.Equals(Symbol.Play))
    {
        play.Symbol = Symbol.Pause;
    }
    else if (play.Symbol.Equals(Symbol.Pause))
    {
        play.Symbol = Symbol.Play;
    }
}

, - .

+11

Source: https://habr.com/ru/post/1627636/


All Articles