Skip to content

Commit 6e21d87

Browse files
committed
Add ShowDetailedExtension for Pickers
1 parent 258303d commit 6e21d87

2 files changed

Lines changed: 21 additions & 7 deletions

File tree

dev/DevWinUI/Common/Picker/FilePicker.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ namespace DevWinUI;
88
[Experimental]
99
public class FilePicker
1010
{
11-
public PickerOptions Options { get; set; } = PickerOptions.None;
11+
public PickerOptions Options { get; set; } = PickerOptions.None;
1212

13+
public bool ShowDetailedExtension { get; set; } = true;
1314
public string? CommitButtonText { get; set; }
1415
public string? SuggestedFileName { get; set; }
1516
public string? DefaultFileExtension { get; set; }
@@ -105,8 +106,14 @@ private unsafe List<string> OpenFileDialog(IntPtr hwnd, bool allowMultiple)
105106

106107
foreach (var kvp in FileTypeChoices)
107108
{
108-
string extensions = string.Join(", ", kvp.Value);
109-
string displayName = $"{kvp.Key} ({extensions})";
109+
string displayName = kvp.Key;
110+
111+
if (ShowDetailedExtension)
112+
{
113+
string extensions = string.Join(", ", kvp.Value);
114+
displayName = $"{kvp.Key} ({extensions})";
115+
}
116+
110117
string spec = string.Join(";", kvp.Value);
111118
filters.Add(new COMDLG_FILTERSPEC { pszName = (char*)Marshal.StringToHGlobalUni(displayName), pszSpec = (char*)Marshal.StringToHGlobalUni(spec) });
112119
}

dev/DevWinUI/Common/Picker/SavePicker.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using Microsoft.UI.Xaml;
2-
using Windows.Foundation.Metadata;
1+
using Windows.Foundation.Metadata;
32
using Windows.Win32.System.Com;
43
using Windows.Win32.UI.Shell;
54
using Windows.Win32.UI.Shell.Common;
@@ -10,6 +9,8 @@ namespace DevWinUI;
109
public class SavePicker
1110
{
1211
public PickerOptions Options { get; set; } = PickerOptions.None;
12+
13+
public bool ShowDetailedExtension { get; set; } = true;
1314
public string? CommitButtonText { get; set; }
1415
public string? SuggestedFileName { get; set; }
1516
public string? DefaultFileExtension { get; set; }
@@ -103,8 +104,14 @@ private async Task<StorageFile> GetStorageFileOrCreateAsync(string filePath)
103104

104105
foreach (var kvp in FileTypeChoices)
105106
{
106-
string extensions = string.Join(", ", kvp.Value);
107-
string displayName = $"{kvp.Key} ({extensions})";
107+
string displayName = kvp.Key;
108+
109+
if (ShowDetailedExtension)
110+
{
111+
string extensions = string.Join(", ", kvp.Value);
112+
displayName = $"{kvp.Key} ({extensions})";
113+
}
114+
108115
string spec = string.Join(";", kvp.Value);
109116
filters.Add(new COMDLG_FILTERSPEC { pszName = (char*)Marshal.StringToHGlobalUni(displayName), pszSpec = (char*)Marshal.StringToHGlobalUni(spec) });
110117
}

0 commit comments

Comments
 (0)