AppBarButton.Icon property

Applies to Windows and Windows Phone

Gets or sets the graphic content of the app bar button.

Syntax


public IconElement Icon { get; set; }


<AppBarButton Icon="symbolName" .../>



<AppBarButton>
    <AppBarButton.Icon>
        iconElement
    </AppBarButton.Icon>
</AppBarButton>


XAML Values

symbolName

A named constant of the Symbol enumeration.

iconElement

A single object element that derives from IconElement and describes the graphic content of the button. The object element is typically one of these classes: SymbolIcon, FontIcon, or PathIcon.

Property value

Type: IconElement

The graphic content of the app bar button.

Examples

This example shows how to change the Icon and Label of an AppBarButton that's initially defined in XAML. This code toggles a button between Play and Pause.

For more examples, see the AppBarButton class.



<Page.BottomAppBar>
    <CommandBar>
        <AppBarButton x:Name="PlayPauseButton" Tag="play" Icon="Play" Label="Play" Click="PlayPauseButton_Click"/>
        <AppBarButton Icon="Stop" Label="Stop" Click="StopButton_Click"/>
    </CommandBar>
</Page.BottomAppBar>



private void PlayPauseButton_Click(object sender, RoutedEventArgs e)
{
    // Using the Tag property value lets you localize the Label value
    // without affecting the app code.
    if ((string)PlayPauseButton.Tag == "play")
    {
        PlayPauseButton.Icon = new SymbolIcon(Symbol.Pause);
        PlayPauseButton.Label = "Pause";
        PlayPauseButton.Tag = "pause";
    }
    else
    {
        PlayPauseButton.Icon = new SymbolIcon(Symbol.Play);
        PlayPauseButton.Label = "Play";
        PlayPauseButton.Tag = "play";
    }  
}

Requirements

Minimum supported client

Windows 8.1

Minimum supported server

Windows Server 2012 R2

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.UI.Xaml.Controls
Windows::UI::Xaml::Controls [C++]

Metadata

Windows.winmd

See also

AppBarButton
Symbol
IconElement
SymbolIcon
FontIcon
PathIcon

 

 

Show:
© 2014 Microsoft