I came up with a different approach. Hope this helps.
The idea is to use the AppBarToggleButton Checked State.
Create another class that extends AppBarToggleButton .
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Input; namespace <YOUR_NAMESPACE> { sealed class SecondaryIconButton : AppBarToggleButton { public static readonly DependencyProperty GlyphProperty = DependencyProperty.Register( "Glyph", typeof( string ), typeof( SecondaryIconButton ) , new PropertyMetadata( SegoeMDL2.Accept, OnGlyphChanged ) ); public string Glyph { get { return ( string ) GetValue( GlyphProperty ); } set { SetValue( GlyphProperty, value ); } } private TextBlock GlyphText; public SecondaryIconButton( string Glyph ) :base() { IsChecked = true; this.Glyph = Glyph; } protected override void OnApplyTemplate() { base.OnApplyTemplate(); GlyphText = ( TextBlock ) GetTemplateChild( "OverflowCheckGlyph" ); GlyphText.Width = GlyphText.Height = 16; UpdateGlyph(); }
Note that SegeoMDL2.Accept also a custom class derived from:
https://msdn.microsoft.com/windows/uwp/style/segoe-ui-symbol-font
Now you can call this in your xaml with:
<ns:SecondaryIconButton Glyph="" />
Or create it in the code behind:
new SecondaryIconButton( Glyph ) { Label = Label };
Reference:
SecondaryIconButton.cs
SegoeMDL2.cs
source share