title: DialogResult in F#
body: <p>Trying to retrieve a DialogResult from a window in a MVVM app, I stumbled on <a href="https://stackoverflow.com/questions/28446568/dependency-property-in-f">this previous question</a>. After implementing the suggested changes, the sample looks like:</p>
  
  <pre><code>type DialogCloser() =
  
      static let DialogResultProperty =
          DependencyProperty.RegisterAttached("DialogResult", typeof&lt;bool&gt;, typeof&lt;DialogCloser&gt;, new PropertyMetadata(DialogResultChanged))
  
      static member GetDialogResult (a:DependencyObject) =
          a.GetValue(DialogResultProperty) :?&gt; bool
  
      static member SetDialogResult (a:DependencyObject) (value:string) = 
          a.SetValue(DialogResultProperty, value)
  
      member this.DialogResultChanged (a:DependencyObject) (e:DependencyPropertyChangedEventArgs) =
          let window = a :?&gt; Window
          match window with
          | null -&gt; failwith "Not a Window"
          | _ -&gt; window.DialogResult &lt;- System.Nullable (e.NewValue :?&gt; bool)
  </code></pre>
  
  <p>Now <code>DialogResultChanged</code> is used before it is declared, which of course doesn't compute in F#.</p>
  
  <p>I can't seem to find a working solution, any help would be appreciated .</p>