SetStorageId property

5 posts, 0 answers
  1. pat
    pat avatar
    14 posts
    Member since:
    Aug 2011

    Posted 08 Aug 2011 Link to this post

    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

  2. Alex Fidanov
    Admin
    Alex Fidanov avatar
    636 posts

    Posted 09 Aug 2011 Link to this post

    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 >>

  3. DevCraft banner
  4. BONIN
    BONIN avatar
    4 posts
    Member since:
    Nov 2010

    Posted 24 Aug 2011 Link to this post

    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();
        }
     
    }

  5. Alex Fidanov
    Admin
    Alex Fidanov avatar
    636 posts

    Posted 25 Aug 2011 Link to this post

    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 >>

  6. BONIN
    BONIN avatar
    4 posts
    Member since:
    Nov 2010

    Posted 26 Aug 2011 Link to this post

    Hi,

    it works very well. thank you very much
Back to Top
DevCraft banner