0
votes

I have a list of hyperlink button, created at runtime

public void SaveBookmark()
        {
            Button objButton = new Button();
            objButton.Content = "Delete";
            objButton.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            objButton.Foreground = new SolidColorBrush((Colors.Black));
            objButton.BorderBrush = new SolidColorBrush((Colors.Black));

            HyperlinkButton objhyperlinkbtn = new HyperlinkButton();
            objhyperlinkbtn.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            objhyperlinkbtn.FontSize = 34;
            objhyperlinkbtn.Foreground = new SolidColorBrush((Colors.Black));
            objhyperlinkbtn.Tag = Index;

            stackpanel.Children.Add(objhlbBookMark);
            stackpanel.Children.Add(objButton);

        }

I want to save it in isolated storage. please help me to save it in isolated storage. I want to give user to choose bookmark if user save a bookmark then hyperlink button save on the page to view list of bookmarks

2
Don't rally understand, why you want to save UI Elements to the isolated storage. Can you give us some more information here? - Robin-Manuel Thiel
Actually I give user to choose bookmark if user save a bookmark then hyperlink button save on the page to view list of bookmarks - Rizwan Qureshi
@RizwanQureshi, there's no point of saving the UI control to isolatedStorage. I think, you should use xml serialization to save the properties of the current item to isolatedStorage. So, when you'll need to build a control with same properties on different page, you can just load properties from xml file. - Olter
+1 more suggestion you can save only info, about the page state or you can keep the control type on ISO (isolated storage). There is no point to store UI control. - Pavan

2 Answers

0
votes

You can "save" button itself in your code (just leave as it is).

However, you'd want to save hyperlinks themselves. If you need readability (so you can open and read file, which contains hyperlinks, via "Windows Phone Power Tools"), then use json for writing file (sample and screenshots included). Otherwise, use binary stream (sample included).

0
votes

Well if I am getting your point correctly then. make a wrapper class first

 public class HypProperties
    {
     public string contentText{get;Set;}
    public double Height{get;Set;}
    public double Width{get;Set;}
//othere properties add according to requirements
    }

Now You can use IsolatedStorageSettings.ApplicationSettings to save an object inside. Sample- To save -

HypProperties obj=new HypProperties (){contentText="",Height=height,Width=width};
if(!IsolatedStorageSettings.ApplicationSettings.Contains("KeyName"))
{
IsolatedStorageSettings.ApplicationSettings["KeyName"]=obj;
IsolatedStorageSettings.ApplicationSettings.Save();
}

To retrieve

if(IsolatedStorageSettings.ApplicationSettings.Contains("KeyName"))
        {
        HypProperties obj=IsolatedStorageSettings.ApplicationSettings["KeyName"] as HypProperties;
        }

But I would suggest you to just store the properties of that hyperlink button. Saving a UI Element is not the correct way.