ich mit einem anderen habe kommen Ansatz. Hoffe das hilft.
Die Idee besteht darin, den Checked Zustand eines AppBarToggleButton
zu verwenden.
Erstellen Sie eine weitere Klasse, die erweitert 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();
}
// Force the button to always be checked
protected override void OnPointerReleased(PointerRoutedEventArgs e)
{
base.OnPointerReleased(e);
IsChecked = true;
}
private void UpdateGlyph()
{
if (GlyphText == null) return;
GlyphText.Text = Glyph;
}
private static void OnGlyphChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
((SecondaryIconButton) d).UpdateGlyph();
}
}
}
Beachten Sie, dass SegeoMDL2.Accept
ist auch eine benutzerdefinierte Klasse, abgeleitet von:
https://msdn.microsoft.com/windows/uwp/style/segoe-ui-symbol-font
Jetzt können Sie dies in Ihrem XAML aufrufen mit:
<ns:SecondaryIconButton Glyph="" />
Oder schaffen es hinter in Code:
new SecondaryIconButton(Glyph) { Label = Label };
Referenz:
SecondaryIconButton.cs
SegoeMDL2.cs
Zum Beispiel, wenn Sie den Outlook-Mail-App öffnen, wenn Sie auf dem CommandBar auf „mehr“ klicken sie zeigt Symbole für jedes Element darin. [Image] (http://s8.postimg.org/x0c5hlgvp/wp_ss_20151217_0001.png) –
Es ist nicht, weil "es in Windows (Phone)" ist, dass es out of the Box für uns Entwickler funktioniert. Das ist ein Fehler, den viele Kunden von uns machen und verlangen. Aber wie bereits erwähnt, können Sie die Standardstile selbst überschreiben. – Bart
Ok ich guck mal, danke für deine Hilfe. –