I am in the process of learning F# and find the FsEmptyWindowsApp that uses FsXaml really useful for throwing together a UI for f# system. One issue I just cannot seem to be able to overcome is opening a new window from my startup MainWindow.xaml. I have created a ChildWindow.xaml and created a type using XAML provider in FsXaml but when I
type MainView = XAML<"MainWindow.xaml", true>
type ChildWindow = XAML<"ChildWindow.xaml",true>
type MainViewModel() as self =
inherit ViewModelBase()
...
member x.NewChildWindowCommand =
new FunCommand ((fun action ->
let cw = ChildWindow()
cw.Root.Activate() |> ignore
),
(fun canExecute -> true))
I always get an error when I run the command stating "cannot locate resource ChildWindow.xaml", I have put it in the project above MainWindow.xaml with its own code behind and always get the, cannot locate resource error.
I have tried manually loading xaml using
Application.LoadComponent(new Uri("/<asseblyname>;component;/ChildWindow.xaml",UriKind.Relative))
but once again same error regarding cannot locate resource...
Any help and explanation as to how I should be using XAML type provider (FxXaml) in FsEmptyWindowsApp to open a new window would be greatly appreciated. alternatively if anyone knows how to do page navigation with FsXaml that would be very useful. I have downloaded the Demos and non of them seem to cover multi-paged/-windowed demos
I figured out the issue, on the newly created xaml files you need to go into the properties and set build action to resource ... now everything works as expected, wish I had figured this out sooner as been evading me for weeks
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With