简体   繁体   中英

Mute Button for all MediaElement in WP8 app

I'm trying to create a mute button for my app at MainPage.xaml , so when i click it every mediaelement in other xaml pages also mute

I use a button to control this bool variable (which i put it in MainPage.xaml)

public static bool isMuted { get; set; }

and in every mediaelement in apps i use this binding

<MediaElement x:Name="MESong" IsMuted="{Binding IsMuted}"/>

but this binding 's not working ?

try this :

<MediaElement x:Name="MESong" IsMuted="{Binding isMuted}"/>

You are using isMuted Property so you need to bind that.

update: I don't know why but when i updated the code and implemented INotifyPropertyChanged, it's work :|

private bool _isMuted;
public bool IsMuted
{
    get { return _isMuted; }
    set
    {
        if (value != _isMuted)
        {
            _isMuted = value;
            NotifyPropertyChanged("IsMuted");
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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