【问题标题】:What replaces the obsolete property Window.PersistId什么取代了过时的属性 Window.PersistId
【发布时间】:2013-04-15 09:53:15
【问题描述】:

我正在使用以下代码:

http://www.codeproject.com/Articles/15926/Save-and-Restore-the-Location-Position-and-State-o

保留我的 XAML 窗口位置。

#region WindowApplicationSettings Helper Class
public class WindowApplicationSettings : ApplicationSettingsBase
{
    private WindowSettings windowSettings;

    public WindowApplicationSettings(WindowSettings windowSettings)
        : base(windowSettings.window.PersistId.ToString())
    {
        this.windowSettings = windowSettings;
    }

不幸的是,该代码使用了微软现已废弃的 Window.PersistId。

"PersistId 是一个过时的属性,将来可能会被删除 释放。此属性的值未定义。”

替换此属性的最佳方法是什么?

【问题讨论】:

    标签: wpf application-settings


    【解决方案1】:

    我不知道应该使用哪个属性来代替 PersistId。 我找到了这个解决方案来保留窗口设置。不过我自己没试过。

    http://www.thomaslevesque.com/2008/11/18/wpf-binding-to-application-settings-using-a-markup-extension/

    【讨论】:

    • 谢谢,我确实看到了这个,但它不适用于最大化窗口或显示器数量减少时(即远程登录)。
    • 好吧,我不知道。您也许可以使用 Uid 属性。您只需要在每个控件上设置它。
    猜你喜欢
    • 2014-02-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多