如何在独立存储中保存超链接按钮 [英] how to save hyperlink button in isolated storage

查看:24
本文介绍了如何在独立存储中保存超链接按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个超链接按钮列表,在运行时创建

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

推荐答案

好吧,如果我正确理解你的观点.先做一个包装类

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
    }

现在你可以使用IsolatedStorageSettings.ApplicationSettings来保存一个对象.样本-保存 -

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

检索

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

但我建议您只存储该超链接按钮的属性.保存 UI 元素不是正确的方法.

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

这篇关于如何在独立存储中保存超链接按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆