如何验证,只允许用户选择1个文件来阅读?

时间:2011-07-05 03:17:48

标签: validation windows-phone-7 controls isolatedstorage

以下是允许用户阅读文件的代码。如何让用户只选择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.");
                }
            }

1 个答案:

答案 0 :(得分:1)

model.Files.Any(file => file.IsChecked)替换为model.Files.Count(file => file.IsChecked) == 1