Hide extensions in Vista/Windows 7 WPF FileDialog.Filter

I am using the WPF OpenFileDialog and SaveFileDialog in my .NET 4 WPF application. I use the Filter property to allow the user to set different file filters. In .NET 4, this uses the native file dialogs introduced with Windows Vista (if possible).

However, these dialogs show the extensions which make up the file filters. Since some of these use quite a bit of extensions, this is quite ugly.

For example, I have a filter Image files|*.bmp;*.dib;*.jpg;*.jpeg;*.jpe;*.jfif;*.gif;*.tif;*.tiff;*.png;*.ico|All files|*.*, which is displayed as Image files (*.bmp;*.dib;*.jpg;*.jpeg;*.jpe;*.jfif;*.gif;*.tif;*.tiff;*.png;*.ico) in the dialog. Everything in the parenthesis is automatically added, i.e. according to the Filter string, it should display Image files. But somewhere the stuff in the parenthesis is added. I tried looking at the code with Reflector to see if it is done somewhere, but quickly gave up since it is quite convoluted.

Starting Paint, for example, I can see that it is possible to use these file dialogs without the stuff in the parenthesis, i.e. it shows Image files.

Does anyone know a workaround for this "feature"?

7
задан Daniel Rose 20 April 2011 в 15:49
поделиться