在 Xaml 文件中我有
<ComboBox Grid.Row="2" Grid.Column="2" Margin="50,50,50,50" FontSize="50" SelectionChanged="NavigateKing">
<ComboBoxItem></ComboBoxItem>
<ComboBoxItem Content="Prince Wijaya"></ComboBoxItem>
<ComboBoxItem Content="Pandukabhaya"></ComboBoxItem>
<ComboBoxItem Content="Dewanampiya Tissa"></ComboBoxItem>
</ComboBox>
在 Xaml.Cs 文件中
private void NavigateKing(object sender, SelectionChangedEventArgs e)
{
ComboBoxItem cbi = (ComboBoxItem)((sender as ComboBox).SelectedItem);
string navigatingURI = cbi.Content.ToString();
this.Frame.Navigate(typeof(/*IntendedXaml filename should be here*/);
}
我可以只传递 NavigationURI 来导航,而不是编写整个 if-else 或 switch-case 场景吗?