简体   繁体   中英

How to show image icon instead of text in ToggleButton in Windows Phone 8.1?

This is the XAML code for a simple toggle button in Windows Phone 8.1.

<ToggleButton Content="Text_Here" />

How can we show an icon for the same Toggle Button??

First you can try if the AppBarToggleButton fits your needs. It toggles an Icon.

Else, you have to edit the ControlTemplate for the ToggleButton. (In Designer: Right click it, got Edit Template -> Edit a Copy).

The default Template features two content presenters for enabled and disabled content, which you can replace to display your icons.

ToggleButton has ContentPresenter inside - you can put most of things into it for example icon:

<ToggleButton>
     <SymbolIcon Symbol="Message"/>
</ToggleButton>

or Image if you want:

<ToggleButton>
     <Image Source="image.jpg"/>
</ToggleButton>

or any Panel , Button another ToggleButton and so on.

You can also play with its Style and Enabled/Disabled Content .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM