如何在c#的SelectionChanged方法中通过按钮更改Uri
本文关键字:按钮 Uri 方法 SelectionChanged | 更新日期: 2023-09-27 18:09:55
我用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;
}
}
任何人? ?
可以使用切换按钮。
<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
作为应用栏按钮样式,请查看此