我想更改应用栏按钮的图标,一旦选中它就会切换,然后再取消选中。我确信使用了.icon属性,但我不知道该如何设置它。我想在每次点击时将其从播放按钮更改为暂停按钮。
private void abtnTimer_Clicked(object sender, RoutedEventArgs e)
{
AppBarToggleButton btn = sender as AppBarToggleButton;
if (btn.IsChecked == true)
{
btn.Icon = //not sure what this should be
string s = DateTime.Now.ToString();
localSettings.Values["Timer"] = s;
}
else
{
btn.Icon = //turn the icon into a play icon
DateTime dte = Convert.ToDateTime(localSettings.Values["Timer"]);
TimeSpan t;
t = DateTime.Now.Subtract(dte);
txtblkHoursData.Text = t.ToString();
}
}
答案 0 :(得分:3)
将其设置为SymbolIcon - 播放播放符号:
btn.Icon = new SymbolIcon(Symbol.Play);
暂停符号暂停:
btn.Icon = new SymbolIcon(Symbol.Pause);