wpff#fsxamlfsharp.viewmodule

f# xaml "this.factory" does not contain CommandSync


I have a strange error with fsxaml and F#. I have a view model and I want to make a call to CommandSync from the factory property but it's not available. Actually it's empty, no functions available. What am I missing here?

code :

namespace ViewModels

open ViewModule


type MainViewModel() as this =
    inherit ViewModelBase()

    let launch() = this.Factory.CommandSync(fun _ -> ())

    member this.LaunchBtn = launch()

P.S I have the ViewModule reference already


Solution

  • In the ViewModule source in the Factory.fs file, there's a comment:

    The F# API is implemented with members having the following signatures via extension methods in the ViewModule.FSharp namespace:

    and CommandSync is listed among those extension methods. Since they're extension methods, they won't be available until the ViewModule.FSharp namespace is opened. You've opened the ViewModule namespace, but you may also need to add:

    open ViewModule.FSharp
    

    to your code. Once you do that, I think the CommandSync methods (and all the other methods on the Factory property) should become available to you.