First, create a dummy windows phone app.
Second, add a text box. The only thing we need to add to this text box is data binding feature. To do that, we open XAML editor and add the following:
Text="{Binding Name}"
to our textbox, that's it.
Third, in our C# code, we need to add a property to connect with the Texbox. Below is my example.
namespace PhoneApp2
{
public class Student
{
public string Name { get; set; }
public string Lastname;
}
public partial class MainPage : PhoneApplicationPage
{
private Student _firstStudent;
// Constructor
public MainPage()
{
InitializeComponent();
Loaded += MainPage_Loaded;
// Sample code to localize the ApplicationBar
//BuildLocalizedApplicationBar();
}
void MainPage_Loaded(object sender, RoutedEventArgs e)
{
_firstStudent = new Student()
{
Name = "Joseph Doors"
};
ContentPanel.DataContext = _firstStudent;
}
}
}
This should produce an output similar to this:
0 comments:
Post a Comment