I have created two pages in the application ... There on the front page Tkstpeix write your name when entering the storage and set up the application on this page, And when you enter the second page in the application name does not come out!
Example: When I open the app and type in my name "Ibra" the text box on the second page my name does not appear!
->Page1:
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));
}
}
-->Page2:
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: (in in the file /Model)
class UserData
{
public string UserName { get; set; }
}
note: I work in windows phone 8.1 silverlight
You set the DataContext
to ObjUserData
but you never put anything for ObjUserData.UserName
, hence it comes back as blank.