标签:style blog http io color ar os for sp
<Window x:Class="demo.OpenFileTest" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="OpenFileTest" Height="300" Width="300"> <DockPanel Margin="5"> <Button DockPanel.Dock="Top" Click="cmdOpen_Click" >open</Button> <ListBox Name="lstFiles"></ListBox> </DockPanel> </Window>
OpenFileTest(窗体类)
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; using Microsoft.Win32; namespace demo { /// <summary> /// OpenFileTest.xaml 的交互逻辑 /// </summary> public partial class OpenFileTest : Window { public OpenFileTest() { InitializeComponent(); } private void cmdOpen_Click(object sender,RoutedEventArgs e) { OpenFileDialog myDialog = new OpenFileDialog(); myDialog.Filter = "Image Files(*.BMP;*.JPG;*.Gif)|*.BMP;*.JPG;*.Gif" + "|All Files(*.*)|*.*"; //检查文件是否存在 myDialog.CheckFileExists = true; //设置文件可以多选 myDialog.Multiselect = true; if (myDialog.ShowDialog() == true) { lstFiles.Items.Clear(); foreach (string file in myDialog.FileNames) { //lstFiles为ListBox的名称 lstFiles.Items.Add(file); } } } } }
MessageBox.Show("提示内容", "提示标题", MessageBoxButton.OKCancel, MessageBoxImage.Exclamation);
D23_02_窗口交互 OpenFileDialog MessageBox
标签:style blog http io color ar os for sp
原文地址:http://www.cnblogs.com/xiepengtest/p/4069025.html