private async void Play_Click(object sender, RoutedEventArgs e) { if ((sender as Button).Content.ToString() == "Play") { if (NameMusic.Text == "Name music: ") { var msg1 = new MessageDialog("The file was not selected.").ShowAsync(); return; } (sender as Button).Content = "Pause"; if (Player.CurrentState == MediaElementState.Stopped || Player.CurrentState == MediaElementState.Closed) { Player.SetSource(await file.OpenReadAsync(), ""); } Player.Play(); } else { (sender as Button).Content = "Play"; Player.Pause(); } }