Ibraheem Osama Mohamed (ابراهيم اسامه محمد)

Welcome to my blog :)

Changing AppBarButton Icon on Run time in Windows 8 (Windows 8.1)

leave a comment »

Today I was testing the AppBarButton in Windows 8.1 and I thought of what if I want to change the Icon of the AppBarButton ex : from zoom out to zoom in??

<AppBarButton Click=”Zoom_Click_1″ Label=”Zoom Out” Icon=”ZoomOut” Name=”ZoomOutButton”/>

4

Just change the Icon property on the button click event but take care of something Icon Property takes IconElement and there are 3 class that inherits from it

FontIcon
PathIcon
SymbolIcon

So you can use any of those class to change the AppBarButton Icon in this sample I used the SymbolIcon

bool IsZoomIn = false;

        privatevoid Zoom_Click_1(object sender, RoutedEventArgs e)

        {

            if (!IsZoomIn)

            {

                ZoomOutButton.Label = “Zoom In”;

                ZoomOutButton.Icon = newSymbolIcon(Symbol.ZoomIn);

                IsZoomIn = true;

            }

            else

            {

                ZoomOutButton.Label = “Zoom Out”;

                ZoomOutButton.Icon = newSymbolIcon(Symbol.ZoomOut);

                IsZoomIn = false;

            }

        }

5

So simple 🙂

2056910448_thanks_xlarge

Ibraheem Osama Mohamed
[MVP]
@IbraheemOM

Advertisements

Written by Ibraheem Osama Mohamed

November 9, 2013 at 1:10 pm

Posted in C#, Windows 8, Windows 8.1, xaml

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: