Telerik PersistenceFramework:RadGridView PersistenceManager.StorageId

问题描述 投票:0回答:1

我正在尝试在telerik:PersistenceManager.StorageId上使用RadGridView属性来保持组件状态在本地存储中。

如果我像这样设置属性:

telerik:PersistenceManager.StorageId="rgvItems"

一切正常但我想用绑定动态设置StorageId。为此,我试图像这样设置属性:

telerik:PersistenceManager.StorageId="{Binding Path=StorageId}"

其中StorageId是组件DependecyProperty文件中定义的xaml.cs

    public string StorageId
    {
        get
        {
            return (string) GetValue(StorageIdProperty);
        }
        set
        {
            SetValue(StorageIdProperty, value);
        }
    }
    public static readonly DependencyProperty StorageIdProperty = 
        DependencyProperty.Register("StorageId", typeof(string), typeof(vGridContainer));

并在组件构造函数中设置如下:

    public vGridContainer(string storageId)
    {
        InitializeComponent();
        DataContext = this;

        StorageId = ConfigurationManager.AppSettings["PersistenceManager.StorageId"]

        [...]
    }

使用该代码,网格视图状态不会保留。

我错过了什么吗?

谢谢大家 :)

data-binding telerik persistence dependency-properties radgridview
1个回答
0
投票

我已经尝试过从xaml绑定属性的所有内容,但没有任何效果。

最后,我解决了从代码中设置附加依赖项属性的问题,如下所示:

rgvCheckIn.SetValue(Telerik.Windows.Persistence.PersistenceManager.StorageIdProperty, ConfigurationManager.AppSettings["PersistenceManager.StorageId"]);

现在它工作正常。希望能帮助遇到同样问题的人:)

© www.soinside.com 2019 - 2024. All rights reserved.