title: How to set Title for OpenFolderDialog in an Avalonia application?
body: <p>I'm working with <code>OpenFileDialog</code>, <code>SaveFileDialog</code> and <code>OpenFolderDialog</code> in an Avalonia application.<br>
  One requirement is to set the title to a certain string.<br>
  I achieved this for <code>OpenFileDialog</code> and <code>SaveFileDialog</code> but <strong>not</strong> for <code>OpenFolderDialog</code>.<br>
  <code>OpenFolderDialog</code> resists applying the title, so that only a default title according the language of the operating system remains set.<br>
  <br>
  I found that in <a href="https://github.com/AvaloniaUI/ControlCatalogStandalone" rel="noreferrer">ControlCatalogStandalone</a> the <code>OpenFolderDialog</code> works correct, i.e. the title can be set as desired.<br>
  So, I tried to reduce <strong>ControlCatalogStandalone</strong> to the <strong>Dialogs</strong> functionality and transform it to be as similar as possible to my test application.<br>
  I couldn't achieve that, but I found some clue that might help a more skilled developer to find the reason for the misbehavior of my test application.<br>
  <br>
  The <strong>Solution</strong> and the <strong>Project</strong>s of <strong>ControlCatalogStandalone</strong> are structured and composed much different to my Avalonia test application.<br>
  In my test application the target framework is <code>.NET Core 3.1</code>.<br>
  In one Project of the <strong>ControlCatalogStandalone</strong> Solution the target framework is <code>.NET Standard 2.0</code>.<br>
  So, I think <code>OpenFolderDialog</code> works correct in <code>.NET Standard</code> but not in <code>.NET Core</code>.<br>
  I also think that if <strong>ControlCatalogStandalone</strong> was built from scratch with the current version of the <code>Avalonia for Visual Studio</code> Extension, it wouldn't produce a mix of frameworks.<br>
  <br>
  Here are the relevant code parts of my test application:<br>
  <br>
  MainWindow.axaml:</p>
  <pre><code>&lt;Window xmlns=&quot;https://github.com/avaloniaui&quot;
          xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
          xmlns:vm=&quot;clr-namespace:DialogTests.ViewModels;assembly=DialogTests&quot;
          xmlns:d=&quot;http://schemas.microsoft.com/expression/blend/2008&quot;
          xmlns:mc=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;
          mc:Ignorable=&quot;d&quot; Width=&quot;200&quot; Height=&quot;150&quot;
          x:Class=&quot;DialogTests.Views.MainWindow&quot;
          Icon=&quot;/Assets/avalonia-logo.ico&quot;
          Title=&quot;DialogTests&quot;&gt;
  
      &lt;Design.DataContext&gt;
          &lt;vm:MainWindowViewModel/&gt;
      &lt;/Design.DataContext&gt;
  
      &lt;Grid RowDefinitions=&quot;*,*,*&quot;&gt;
          &lt;Button Grid.Column=&quot;0&quot; Grid.Row=&quot;0&quot; Command=&quot;{Binding OpenFileDialogCommand}&quot; Content=&quot;OpenFileDialog&quot;/&gt;
          &lt;Button Grid.Column=&quot;0&quot; Grid.Row=&quot;1&quot; Command=&quot;{Binding SaveFileDialogCommand}&quot; Content=&quot;SaveFileDialog&quot;/&gt;
          &lt;Button Grid.Column=&quot;0&quot; Grid.Row=&quot;2&quot; Command=&quot;{Binding OpenFolderDialogCommand}&quot; Content=&quot;OpenFolderDialog&quot;/&gt;
      &lt;/Grid&gt;
  
  &lt;/Window&gt;
  </code></pre>
  <p>MainWindowViewModel.cs:</p>
  <pre><code>using Avalonia.Controls;
  using DialogTests.Views;
  using ReactiveUI;
  using System.Collections.Generic;
  using System.Reactive;
  
  namespace DialogTests.ViewModels
  {
      public class MainWindowViewModel : ViewModelBase
      {
          public MainWindowViewModel()
          {
              OpenFileDialogCommand = ReactiveCommand.Create(() =&gt; {
                  new OpenFileDialog()
                  {
                      Title = &quot;Open File Dialog&quot;,
                      Filters = GetFilters()
                  }.ShowAsync(MainWindow.Instance);
              });
  
              SaveFileDialogCommand = ReactiveCommand.Create(() =&gt;
              {
                  new SaveFileDialog()
                  {
                      Title = &quot;Save File Dialog&quot;,
                      Filters = GetFilters()
                  }.ShowAsync(MainWindow.Instance);
              });
  
              OpenFolderDialogCommand = ReactiveCommand.Create(() =&gt; {
                  new OpenFolderDialog()
                  {
                      Title = &quot;Open Folder Dialog&quot;
                  }.ShowAsync(MainWindow.Instance);
              });
          }
  
          public ReactiveCommand&lt;Unit, Unit&gt; OpenFileDialogCommand { get; }
          public ReactiveCommand&lt;Unit, Unit&gt; SaveFileDialogCommand { get; }
          public ReactiveCommand&lt;Unit, Unit&gt; OpenFolderDialogCommand { get; }
  
          List&lt;FileDialogFilter&gt; GetFilters()
          {
              return new List&lt;FileDialogFilter&gt;
                  {
                      new FileDialogFilter
                      {
                          Name = &quot;Text files&quot;, Extensions = new List&lt;string&gt; {&quot;txt&quot;}
                      },
                      new FileDialogFilter
                      {
                          Name = &quot;All files&quot;,
                          Extensions = new List&lt;string&gt; {&quot;*&quot;}
                      }
                  };
          }
      }
  }
  </code></pre>
  <p>MainWindow.axaml.cs:</p>
  <pre><code>using Avalonia;
  using Avalonia.Controls;
  using Avalonia.Markup.Xaml;
  
  namespace DialogTests.Views
  {
      public class MainWindow : Window
      {
          public static MainWindow Instance { get; private set; }
          public MainWindow()
          {
              Instance = this;
              InitializeComponent();
  #if DEBUG
              this.AttachDevTools();
  #endif
          }
  
          private void InitializeComponent()
          {
              AvaloniaXamlLoader.Load(this);
          }
      }
  }
  </code></pre>
  <p>I'm showing the last file because I wasn't able to implement the method
  <code>Window GetWindow() =&gt; (Window)this.VisualRoot;</code> in my ViewModel which in <strong>ControlCatalogStandalone</strong> is implemented and used in the code behind of <code>DialogsPage</code> (which actually is a <code>UserControl</code>).<br>
  So, I implemented the <code>Instance</code> property which perhaps is a hack.<br>
  If you also could give me hint on best practice to get the instance of the <code>MainWindow</code> I'd be happy.<br>
  <br>
  Is my problem not being able to set the title in <code>OpenFolderDialog</code> an open issue of the <code>.NET Core</code> implementation, or can you tell me how to get it working in my simple test application?</p>