0

我用 c# 为 windows 8 开发了一个游戏指南应用程序。我试图将 2 个 youtube 视频放在游戏的特定章节中,我想通过一个按钮更改 Webview 的 Uri。当未按下按钮时,将显示第一个视频 uri,当按下按钮时,将显示第二个视频。我怎样才能做到这一点?例如:

    private void Chapters_SelectionChanged(object sender, Windows.UI.Xaml.Controls.SelectionChangedEventArgs e)
    {           
        switch (Chapters.SelectedIndex)
        { 
            case 0:

                Chapter2C.Visibility = Visibility.Visible;
                Chapter2T.Visibility = Visibility.Visible;
                next_but.Visibility = Visibility.Visible;
                prev_but.Visibility = Visibility.Visible;
                Mywebview.Visibility = Visibility.Visible;
                if (next_button.Clicked)
                 {
                    Mywebview.Source = new Uri("http://www.youtube.com/embed/F65paVQ0wn8?feature=player_detailpage") 
                 }
                   else 
                 {
                    Mywebview.Source = new Uri ("http://www.youtube.com/embed/rLdrc7K5vdw");
                 }
                 break;
        }
   }

任何人??

4

1 回答 1

0

您可以使用切换按钮。

<ToggleButton x:Name="btnChangeChapter" Content="Change Chapter" Click="btnChangeChapter_Click_1"/>

private void btnChangeChapter_Click_1(object sender, RoutedEventArgs e)
{
    /* TODO: use property btnChangeChapter.IsChecked.Value in SelectionChanged event,
            it's bool value */
}

如果您想ToggleButton用作应用栏按钮样式,请检查一下

于 2013-04-19T11:53:46.863 回答