Browse Source

update dialogs sample page

pull/7618/head
Luthfi Tri Atmaja 5 years ago
parent
commit
eefe009a81
  1. 17
      samples/ControlCatalog/Pages/DialogsPage.xaml.cs

17
samples/ControlCatalog/Pages/DialogsPage.xaml.cs

@ -42,13 +42,17 @@ namespace ControlCatalog.Pages
this.FindControl<Button>("OpenFile").Click += async delegate this.FindControl<Button>("OpenFile").Click += async delegate
{ {
// Almost guaranteed to exist
var fullPath = Assembly.GetEntryAssembly()?.GetModules().FirstOrDefault()?.FullyQualifiedName;
var initialFileName = fullPath == null ? null : System.IO.Path.GetFileName(fullPath);
var initialDirectory = fullPath == null ? null : System.IO.Path.GetDirectoryName(fullPath);
var result = await new OpenFileDialog() var result = await new OpenFileDialog()
{ {
Title = "Open file", Title = "Open file",
Filters = GetFilters(), Filters = GetFilters(),
Directory = lastSelectedDirectory, Directory = initialDirectory,
// Almost guaranteed to exist InitialFileName = initialFileName
InitialFileName = Assembly.GetEntryAssembly()?.GetModules().FirstOrDefault()?.FullyQualifiedName
}.ShowAsync(GetWindow()); }.ShowAsync(GetWindow());
results.Items = result; results.Items = result;
resultsVisible.IsVisible = result?.Any() == true; resultsVisible.IsVisible = result?.Any() == true;
@ -84,7 +88,12 @@ namespace ControlCatalog.Pages
Title = "Select folder", Title = "Select folder",
Directory = lastSelectedDirectory, Directory = lastSelectedDirectory,
}.ShowAsync(GetWindow()); }.ShowAsync(GetWindow());
lastSelectedDirectory = result;
if (!string.IsNullOrEmpty(result))
{
lastSelectedDirectory = result;
}
results.Items = new [] { result }; results.Items = new [] { result };
resultsVisible.IsVisible = result != null; resultsVisible.IsVisible = result != null;
}; };

Loading…
Cancel
Save