开发者

How to validate, only allowing the user to select 1 file to read?

Below are the codes to allow the user to read a File. How to allow the user to select only 1 file to read?

private v开发者_Go百科oid 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.");
                }
            }


Replace model.Files.Any(file => file.IsChecked) with model.Files.Count(file => file.IsChecked) == 1.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜