0
I am new to Windows Store app and I am connecting to a web service that I have created. I get an object called user that has all the information that I need to populate my controls with and the values are being populated correctly in the object. What I cannot seem to figure out is how to connect the object to the controls on the XAML page. I am currently trying to populate the users first name to the
I have gone through tutorials and I cannot see what I am missing.
Here is the code for my XAML:
Code Behind For That Page:
public sealed partial class MainMenu : Page
{
User usr = new User();
public MainMenu()
{
this.InitializeComponent();
}
///
/// Invoked when this page is about to be displayed in a Frame.
///
/// Event data that describes how this page was reached. The Parameter
/// property is typically used to configure the page.
protected override void OnNavigatedTo(NavigationEventArgs e)
{
usr = (User)e.Parameter;
CurrentUserDataSource cuDS = new CurrentUserDataSource(usr);
}
}
}
CurrentUserDataSource.cs
class CurrentUserDataSource
{
public CurrentUserDataSource()
{
}
public CurrentUserDataSource(User user)
{
LoadUser(user);
}
private ObservableCollection
public ObservableCollection
{
get { return currentUser; }
set { currentUser = value; }
}
private void LoadUser(User user)
{
currentUser = new ObservableCollection
{
new CurrentUser
{
FirstName = user.FirstName,
LastName = user.LastName,
EmailAddress = user.LastName,
LastSignIn = user.LastSignIn,
SignUpdate = user.SignUpdate
}
};
}
}
CurrentUser.cs
class CurrentUser:INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private string _firstname;
private string _lastname;
private DateTime _lastsignin;
private DateTime _signupdate;
private string _emailaddress;
public CurrentUser()
{
}
public CurrentUser(User user)
{
this.FirstName = user.FirstName;
this.LastName = user.LastName;
this.LastSignIn = user.LastSignIn;
this.SignUpdate = user.SignUpdate;
this.EmailAddress = user.EmailAddress;
}
private void NotifyPropertyChanged(string property)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(property));
}
}
public string FirstName
{
get { return this._firstname; }
set
{
_firstname = value;
NotifyPropertyChanged("FirstName");
}
}
public string LastName
{
get { return this._lastname; }
set
{
_lastname = value;
NotifyPropertyChanged("LastName");
}
}
public DateTime LastSignIn
{
get { return this._lastsignin; }
set
{
_lastsignin = value;
NotifyPropertyChanged("LastSignIn");
}
}
public DateTime SignUpdate
{
get { return this._signupdate; }
set
{
_signupdate = value;
NotifyPropertyChanged("SignUpdate");
}
}
public string EmailAddress
{
get { return this._emailaddress; }
set
{
_emailaddress = value;
NotifyPropertyChanged("EmailAddress");
}
}
}
Replies
Know the answer? Post it — somebody with the same question will find it here.