Binding after restore app (WP7)

Topics: Conventions, UI Architecture
Jul 27, 2011 at 8:37 AM
Edited Jul 27, 2011 at 11:32 AM

Hello. I have problem with binding after app is restored after tombstone (start button). 
It works for simple controls, but it doesn't work for embedded control binded with Bind.Model="".

 
<controls:PivotItem Header="ABC">
 <StackPanel>
   <TextBlock Text="{Binding Test}"></TextBlock>    <!-- it works -->
   <v:CustomerView cal:Bind.Model="{Binding CustomerContent}" />  <!-- it doesn't -->
 </StackPanel>
</controls:PivotItem>

Content in CustomerView is very simple, and is based on this type of items :

 <TextBlock x:Name="ProductionToday">1500 kWh</TextBlock>

but it doesn't work neither if I change it to  

  <TextBlock x:Name="ProductionToday" Text="{Binding ProductionToday}"/>

 

I load data this way (probably OnViewLoaded is not right place, but it doesn't work anywhere else, I think) 


protected override void OnViewLoaded(object view) { base.OnViewLoaded(view); load(); } async void load() { await Current.RefreshCustomerDataIfEmpty(); CustomerContent = new CustomerViewModel(); //it loads data from Current.Customer (up) Test = "abc"; Changed(() => Test); //it works Changed(() => CustomerContent); //it doesn't work CustomerContent.Refresh(); //it doesn't this.Refresh(); //it doesn't work }

 

Thank you 
Jul 29, 2011 at 10:39 AM

Ok, my fault. Problem was the await word, which caused some waiting for loading my data for service. Which isn't probably good approach. 

The (beginner's :) solution for me : save data to phone's state (tombstone) and restore them back after restore app. Don't use data services to refresh data :)