WP7中的停止/启动按钮绑定

时间:2012-03-05 09:44:55

标签: wpf windows-phone-7.1

有一个用于在表单和媒体元素上播放音乐的按钮。该按钮用于播放/停止音乐。

是否可以(以及如何)通过单击XAML在按钮内绘制箭头或方块?它必须取决于媒体元素的状态(如果它正在播放或不播放)。如果不可能在后面的代码中怎么做?

P.S。换句话说,音乐播放按钮必须显示正方形,否则必须是箭头(如三角形)。

1 个答案:

答案 0 :(得分:0)

您可以通过代码更改按钮的背景图像。

    if(mediaplays)
    {
        ImageSource img = new BitmapImage(new Uri("imageurl", UriKind.Relative));
        ImageBrush imgb = new ImageBrush();
        imgb.ImageSource = img;

        btn.Background = imgb;//btn is the name of the button
    }