我在应用程序启动时恢复Window的坐标.在Good-old-Windows-Forms中我使用了System.Windows.Forms.Screen集合.WPF世界中有类似的东西吗?
我也注意到PrimaryScreen*,VirtualScreen*参数System.Windows.SystemParameters.然而,他们让我不知所措,因为在监视器尺寸不同的情况下,似乎无法检测Window是否在内边界.
在我的小型WPF应用程序(仅限F#)中,我想在关闭后记住窗口大小和位置.此C#解决方案建议使用项目设置IDictinary for User.config.这看起来像我之后的简单方法,但我没有在我的F#项目中找到项目设置.它们是否存在于F#项目中?
我试过这个但它不起作用:(在C#示例中的save()调用不可用.)
let getSetting k def =
if Application.Current.Properties.Contains k
then Application.Current.Properties.Item k
else def
let window = System.Windows.Window()
// is box() the best wax to make floats into obj ?
window.Top <- getSetting "WindowTop" (box 0.0) |> unbox
window.Left <- getSetting "WindowLeft" (box 0.0) |> unbox
window.Height <- getSetting "WindowHeight" (box 800.0) |> unbox
window.Width <- getSetting "WindowWidth" (box 800.0) |> unbox
window.Closing.Add( fun _ ->
Application.Current.Properties.Add("WindowTop",window.Top)
Application.Current.Properties.Add("WindowHeight",window.Height)
Application.Current.Properties.Add("WindowLeft",window.Left)
Application.Current.Properties.Add("WindowWidth",window.Width)
//Application.Current.Properties.Save() // not available!
) …Run Code Online (Sandbox Code Playgroud)