|
|
@@ -3,12 +3,14 @@ using System.Reactive;
|
|
|
using System.Reactive.Linq;
|
|
|
using System.Threading.Tasks;
|
|
|
using Avalonia.Controls;
|
|
|
+using Avalonia.VisualTree;
|
|
|
using ReactiveUI;
|
|
|
|
|
|
namespace ControlCatalog.ViewModels
|
|
|
{
|
|
|
public class MenuPageViewModel
|
|
|
{
|
|
|
+ public Control View { get; set; }
|
|
|
public MenuPageViewModel()
|
|
|
{
|
|
|
OpenCommand = ReactiveCommand.CreateFromTask(Open);
|
|
|
@@ -65,8 +67,11 @@ namespace ControlCatalog.ViewModels
|
|
|
|
|
|
public async Task Open()
|
|
|
{
|
|
|
+ var window = View?.GetVisualRoot() as Window;
|
|
|
+ if (window == null)
|
|
|
+ return;
|
|
|
var dialog = new OpenFileDialog();
|
|
|
- var result = await dialog.ShowAsync(App.Current.MainWindow);
|
|
|
+ var result = await dialog.ShowAsync(window);
|
|
|
|
|
|
if (result != null)
|
|
|
{
|