如何验证,仅允许用户选择1个文件进行读取? [英] How to validate, only allowing the user to select 1 file to read?
本文介绍了如何验证,仅允许用户选择1个文件进行读取?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下是允许用户读取文件的代码。如何允许用户仅选择1个文件进行读取?
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 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.");
}
}
推荐答案
替换 model.Files.Any(file => file.IsChecked)
与 model.Files.Count(file => file.IsChecked)== 1
。
这篇关于如何验证,仅允许用户选择1个文件进行读取?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文