private void Add_Files_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Multiselect = true;
openFileDialog.Filter = "All Images Files (*.png;*.jpeg;*.gif;*.jpg;*.bmp;*.tiff;*.tif)|*.png;*.jpeg;*.gif;*.jpg;*.bmp;*.tiff;*.tif";
openFileDialog.Filter = "PNG Portable Network Graphics (*.png)|" + "*.png";
openFileDialog.Filter = "JPEG File Interchange Format (*.jpg *.jpeg *jfif)|" + "*.jpg;*.jpeg;*.jfif";
openFileDialog.Filter = "BMP Windows Bitmap (*.bmp)|" + "*.bmp";
openFileDialog.Filter = "TIF Tagged Imaged File Format (*.tif *.tiff)|" + "*.tif;*.tiff";
openFileDialog.Filter = "GIF Graphics Interchange Format (*.gif)|" + "*.gif";
}
这样当我单击按钮时,默认且唯一的选项是GIF文件类型。我无法将其更改为任何其他文件类型。
我希望默认的第一个选项是All Images File,然后我就可以为每种图像格式进行更改。
答案 0 :(得分:1)
使用|
字符加入所有字符串并分配
dialog.Filter = "All Images Files (*.png;*.jpeg;*.gif;*.jpg;*.bmp;*.tiff;*.tif)|*.png;*.jpeg;*.gif;*.jpg;*.bmp;*.tiff;*.tif" +
"|PNG Portable Network Graphics (*.png)|*.png" +
"|JPEG File Interchange Format (*.jpg *.jpeg *jfif)|*.jpg;*.jpeg;*.jfif" +
"|BMP Windows Bitmap (*.bmp)|*.bmp" +
"|TIF Tagged Imaged File Format (*.tif *.tiff)|*.tif;*.tiff" +
"|GIF Graphics Interchange Format (*.gif)|*.gif";