【问题标题】:Isolated storage in In a multi-page c#在多页 c# 中的隔离存储
【发布时间】:2015-08-07 19:38:34
【问题描述】:

我在应用程序中创建了两个页面... 在首页 Tkstpeix 在进入存储时写下您的名字并在此页面上设置应用程序, 而且当你进入第二页的时候应用名称不出来!

示例: 当我打开应用程序并输入我的名字“Ibra”时,第二页上的文本框没有出现我的名字!

->第1页:

using myProject.Model;
public partial class Test1 : PhoneApplicationPage
{
    IsolatedStorageSettings Data = IsolatedStorageSettings.ApplicationSettings;
    List<UserData> ObjUserDataList = new List<UserData>();
    public Test1()
    {
        InitializeComponent();
        this.Loaded += Test1_Loaded;
    }

    private void Test1_Loaded(object sender, RoutedEventArgs e)
    {
        if (Data.Contains("UserNameData"))
        {
            NavigationService.Navigate(new Uri("/Test2.xaml", UriKind.Relative));
        }
    }

    private void NameBox_GotFocus(object sender, RoutedEventArgs e)
    {
        TextBox tb = (TextBox)sender;
        tb.BorderBrush = new SolidColorBrush(Colors.LightGray);
    }

    private void button_Click(object sender, RoutedEventArgs e)
    {
        Data["UserNameData"] = NameBox.Text;
        NavigationService.Navigate(new Uri("/Test2.xaml", UriKind.Relative));
    }
}

-->第2页:

using myProject.Model;
public partial class Test2 : PhoneApplicationPage
{
    IsolatedStorageSettings Data = IsolatedStorageSettings.ApplicationSettings;
    UserData ObjUserData = new UserData();
    public Test2()
    {
        InitializeComponent();
        this.Loaded += Test2_Loaded;
    }

    private void Test2_Loaded(object sender, RoutedEventArgs e)
    {
        if (Data.Contains("UserNameData"))
        {

            StckUserDetailsUI.DataContext = ObjUserData;
        }
    }
}


<StackPanel  Name="StckUserDetailsUI"  Grid.Row="0" Margin="12,17,0,28" Grid.ColumnSpan="2">
            <TextBlock Text="Your Details :" Foreground="White" FontSize="30" TextDecorations="Underline"/>
            <TextBlock FontSize="40" Name="TxtUserName" Text="{Binding UserName}" Foreground="White"/>
        </StackPanel>

--->UserData.Cs:(在文件/Model中)

 class UserData
{
    public string UserName { get; set; }
}

注意: 我在 windows phone 8.1 silverlight 中工作

【问题讨论】:

    标签: c# windows-phone-8.1 iso


    【解决方案1】:

    您将DataContext 设置为ObjUserData,但您从未为ObjUserData.UserName 输入任何内容,因此它返回为空白。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多