WPF 后台绑定样式

 

 private ContentControl cc = null;

private void muiscPlay(object sender, RoutedEventArgs e)
{
string name = ((ContentControl)sender).Tag.ToString();
if (string.IsNullOrWhiteSpace(name))
return;
if (filename != name)
{
player.Stop();
isStart = true;
if (cc != null)
cc.SetResourceReference(System.Windows.Controls.Button.StyleProperty, "playButtonStyle2");
player.LoadedBehavior = MediaState.Manual;
player.Source = new Uri("./Resource/musics/" + name, UriKind.Relative);
filename = name;
}
if (isStart)
{
player.Play();
((ContentControl)sender).SetResourceReference(System.Windows.Controls.Button.StyleProperty, "pauseButtonStyle2");
cc = ((ContentControl)sender);
isStart = false;
}
else
{
player.Pause();
((ContentControl)sender).SetResourceReference(System.Windows.Controls.Button.StyleProperty, "playButtonStyle2");
isStart = true;
}
}

posted @ 2016-08-18 11:21  Hao0  阅读(2435)  评论(0编辑  收藏  举报