This is a migrated thread and some comments may be shown as answers.

SetStorageId property

4 Answers 107 Views
PersistenceFramework
This is a migrated thread and some comments may be shown as answers.
pat
Top achievements
Rank 1
pat asked on 08 Aug 2011, 11:47 PM
I am trying to use the PersistenceFramework and I would like to set the StorageId progamatically.  I am try to give the user the opportunity to save several 'versions' of a gridview.  Is this possible?  According to the docs it would seem that the SetStorageId property is part of the PersistenceManager but it does not show up. Could I get some sample code on this.

Thanks,

PatC

4 Answers, 1 is accepted

Sort by
0
Alex Fidanov
Telerik team
answered on 09 Aug 2011, 09:29 AM
Hello Pat,

Yes, it is possible to keep several versions of one control  by changing its StorageId property. You can change the StorageId value in procedural code by using the static method PersistenceManager.SetStorageId(...) and pass the object and the new string value for storage id. Please note that the StorageId is an attached dependency property, and the static method of the owner class is how you set its value.

PersistenceManager.SetStorageId(this.textBox, "textBox_Version1);


Regards,
Alex Fidanov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
BONIN
Top achievements
Rank 1
answered on 24 Aug 2011, 03:29 PM
Hi,

In my application, I have a composite view of RadTileViewItem; This view can be accessed by multiple undefined users.
I would like each of them to save their configuration.

So I think using the method:
"PersistenceManager.SetStorageId" with the user ID as a key storage.

My question is:

How, according to the user find the right persistence of control, from "ISO".

With the method "GetStorageId" I can not get the proper configuration.
Can you help me?
Here my code XAML:
<telerik:RadTileView x:Name="WidgetTileView" ItemsSource="{Binding RadWidgetPanels}"
                     RowHeight="*" ColumnWidth="*" MinimizedColumnWidth="350"
                     ReorderingDuration="0:0:1" ResizingEasing="{StaticResource ResizingEase}" ReorderingEasing="{StaticResource ResizingEase}" />
 
<Button Content="SaveToIsolateStorage" Click="OnSave" Grid.Row="1"></Button>

And the code behind:
public partial class AccueilView : UserControl
{
    private AccueilViewModel currentDataContext;
    private IsolatedStorageProvider isoProvider = new IsolatedStorageProvider();
 
    public AccueilView()
    {
        InitializeComponent();
 
        this.DataContext = new AccueilViewModel();
        this.currentDataContext = (AccueilViewModel)this.DataContext;
 
        this.Loaded += new RoutedEventHandler(AccueilView_Loaded);
    }
 
    void AccueilView_Loaded(object sender, RoutedEventArgs e)
    {
        PersistenceManager.GetStorageId(this.WidgetTileView);
        this.isoProvider.LoadFromStorage();
    }
 
 
    void OnSave(object sender, System.Windows.RoutedEventArgs e)
    {
        var key = string.Concat("Widget_", this.currentDataContext.CurrentUserId);
        PersistenceManager.SetStorageId(this.WidgetTileView, key);
        this.isoProvider.SaveToStorage();
    }
 
}

0
Alex Fidanov
Telerik team
answered on 25 Aug 2011, 04:55 PM
Hello Bonin,

I have attached a small project demonstrating this requirement. The radio buttons on top simulate different users and generate different storage ids based on which user is active. Then with the Save and Load buttons, the appropriate configuration is saved and loaded on the slider control below. Please let me know if you have questions on this.

Greetings,
Alex Fidanov
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
BONIN
Top achievements
Rank 1
answered on 26 Aug 2011, 08:56 AM
Hi,

it works very well. thank you very much
Tags
PersistenceFramework
Asked by
pat
Top achievements
Rank 1
Answers by
Alex Fidanov
Telerik team
BONIN
Top achievements
Rank 1
Share this question
or