我正在学习 F#,发现使用 FsXaml 的 FsEmptyWindowsApp 对于为 f# 系统构建 UI 非常有用。我似乎无法克服的一个问题是从我的启动 MainWindow.xaml 打开一个新窗口。我创建了一个 ChildWindow.xaml 并使用 FsXaml 中的 XAML 提供程序创建了一个类型,但是当我
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))
当我运行命令“无法定位资源 ChildWindow.xaml”时,我总是收到错误,我已将其放在 MainWindow.xaml 上面的项目中,并带有自己的代码,并且总是收到“无法定位资源”错误。
我尝试使用手动加载xaml
Application.LoadComponent(new Uri("/<asseblyname>;component;/ChildWindow.xaml",UriKind.Relative))
但再次出现关于无法找到资源的相同错误...
任何关于我应该如何在 FsEmptyWindowsApp 中使用 XAML 类型提供程序 (FxXaml) 打开新窗口的帮助和解释将不胜感激。或者,如果有人知道如何使用 FsXaml 进行页面导航,那将非常有用。我已经下载了演示,但似乎没有一个涵盖多页/窗口演示
最佳答案
我解决了这个问题,在新创建的 xaml 文件上,您需要进入属性并将构建操作设置为资源...现在一切都按预期工作,希望我能早点解决这个问题,因为这几周来一直在逃避我
关于.net - F# 和 FsXaml 用于打开新的 xaml 窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28281348/