简体   繁体   English

WP7中的“停止/开始”按钮绑定

[英]Stop/Start button binding in WP7

There's a button for playing music on the form and a media element. 表单和媒体元素上都有一个用于播放音乐的按钮。 The button is used for play/stop the music. 该按钮用于播放/停止音乐。

Is it possible (and how) to draw an arrow or a square inside the button by clicking in XAML? 通过单击XAML是否可以(以及如何)在按钮内绘制箭头或正方形? It must depends on the state of the media element (if it's playing or not). 它必须取决于媒体元素的状态(是否正在播放)。 If it's impossible how to do it in code behind? 如果不可能在后面的代码中怎么做?

PS In other words it the music is playing the button must displays a square, otherwise it's must be an arrow (like a triangle). PS换句话说,正在播放音乐的按钮必须显示一个正方形,否则必须是一个箭头(如三角形)。

You can change the background image of the button through code. 您可以通过代码更改按钮的背景图像。

    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
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM