以下是允许用户阅读文件的代码。如何让用户只选择1个文件来阅读?
private void button3_Click(object sender, RoutedEventArgs e)
{
ViewDiskModel model = this.ContentPanel.DataContext as ViewDiskModel;
if (model.Files.Any(file => file.IsChecked))
{
model.ReadSelectedFiles.Execute(null);
NavigationService.Navigate(new Uri("/AnswerQuestionPage.xaml", UriKind.Relative));
}
else
if ((model.Files.Any(file => file.IsChecked)) > 1)
{
MessageBox.Show("Please Select only 1 File.");
}
}
答案 0 :(得分:1)
将model.Files.Any(file => file.IsChecked)
替换为model.Files.Count(file => file.IsChecked) == 1
。