Hi,
i am writing a wpf applivation with the mvvm pattern. in my viewmodel, i receive the data asynchron over a wcf service:
#region Construction
public AddressViewModel()
{
this.LoadAddress();
}
private async void LoadAddress()
{
ServiceClient client = new ServiceClient();
_address = await client.GetAddressByIdAsync(1);
}
#endregion
I bind the propertys in view like this:
<TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding address1, IsAsync=True}"/>
The UI doesnt update automatically after the asynchron load. When i change a property via button (for example) the UI updates, so the problem must rely on the asynchron WCF-Call. I tried the following changes and they do the job but i think this is not good practice.
private async void LoadAddress()
{
ServiceClient client = new ServiceClient();
_address = await client.GetAddressByIdAsync(1);
RaisePropertyChanged("address1");
}
Do i really have to RaisePropertyChange("propName") for each property of my class or is there a better, cleaner, more elegant way?
EDIT:
Normaly i raise the propertychangeevent in the setter like this:
public string address1
{
get { return Address.address1; }
set
{
if (Address.address1 != value)
{
Address.address1 = value;
RaisePropertyChanged("address1");
}
}
}