title: OpenFileDialog in Avalonia - Error with ShowAsync
body: <p><strong>Background:</strong></p>
  <p>I have been using Avalonia to develop a cross-platform UI. To learn it I am trying to  creating a simple program that opens a .txt file using <code>OpenFileDialog</code> and displays its contents in a <code>ComboBox</code> in another window.</p>
  <p>I am trying to write a method that opens file dialog and returns the path the user opened. I am using a button with a Click event to open file dialog and put the specified path in a <code>TextBox</code> for the user to see. Since I am new to both WPF and Avalonia, I am not sure how to proceed.</p>
  <p><strong>Problem:</strong></p>
  <p>I have created the UI view and a view model. The view model uses <code>INotifyPropertyChanged</code> to display the selected file path in a <code>TextBox</code>, which I have default set to the C drive.</p>
  <p>Now I want to use <code>OpenFileDialog</code> to update that path with the path to the .txt file the user has selected. I found an example that demonstrates <code>OpenFileDialog</code>, but it doesn't seem to work for me and I don't really understand how it should work.</p>
  <p>TxtView.xaml:</p>
  <pre><code>&lt;TextBox Text=&quot;{Binding Path}&quot; Margin=&quot;0 0 5 0&quot; Grid.Column=&quot;0&quot; IsReadOnly=&quot;True&quot; /&gt;
  &lt;Button Content=&quot;Browse&quot; Click=&quot;OnBrowseClicked&quot; Margin=&quot;0 0 0 0&quot; Grid.Column=&quot;1&quot; /&gt;
  </code></pre>
  <p>TxtView.xaml.cs:</p>
  <pre><code>public async Task GetPath()
  {
     var dialog = new OpenFileDialog();
     dialog.Filters.Add(new FileDialogFilter() { Name = &quot;Text&quot;, Extensions = { &quot;txt&quot; } });
     dialog.AllowMultiple = true;
  
     var result = await dialog.ShowAsync();
  
     if (result != null)
     {
        await GetPath(result);
     }
  }
  
  public void OnBrowseClicked(object sender, RoutedEventArgs args)
  {
     var context = this.DataContext as TxtViewModel;
     context.Path = &quot;path&quot;;
  }
  </code></pre>
  <p>TxtViewModel.cs</p>
  <pre><code>class TxtViewModel : INotifyPropertyChanged
  {
     private string _path;
  
     public string Path
     {
        get =&gt; _path;
        set
        {
           if (value != _path)
           {
              _path = value;
              OnPropertyChanged();
           }
        }
     }  
  
     public event PropertyChangedEventHandler PropertyChanged;
  
     protected virtual void OnPropertyChanged([CallerMemberName] string 
     propertyName = null)
     {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
     }
  
  }
  </code></pre>
  <p>The error I am getting with this code is with the <code>ShowAsync()</code> in the <code>TxtView.xaml.cs</code> file. The error says</p>
  <blockquote>
  <p>There is no argument given that corresponds to the required formal parameter 'parent' of 'OpenFileDialog.ShowAsync(Window)'</p>
  </blockquote>
  <p>I have tried <code>ShowAsync(this)</code> which fixes the error with <code>ShowAsync</code> but now gives me the error</p>
  <blockquote>
  <p>Arguement 1: cannot convert from 'Txt2List.Views.TxtView' to 'Avalonia.Controls.Window'</p>
  </blockquote>
  <p>All help is appreciated and I apologize if I am not clear, I am completely new to Avalonia, WPF, and XAML so I am learning. Please let me know if there is additional information I can provide.</p>