Note that there are some explanatory texts on larger screens.

plurals
  1. POView not updating after a property in ViewModel is updated
    primarykey
    data
    text
    <p>So I'm trying to implement a ListBoxItem that has a TextBlock that binds to a property in the viewmodel. But for some reason the view isn't being updated even after the viewmodel property is updated. Can anyone give me some pointers?</p> <p>In the view (xaml)</p> <pre><code>&lt;phone:Pivot HorizontalAlignment="Left" Height="748" Margin="10,10,0,0" Grid.Row="1" Title="pivot" VerticalAlignment="Top" Width="460"&gt; &lt;StackPanel x:Name="POIStackPanel" DataContext="{StaticResource POIViewModel}"&gt; &lt;ListBoxItem x:Name="SelectedPOIItem"&gt; &lt;TextBlock Text="{Binding SelectedPickupPOI.label}" /&gt; &lt;/ListBoxItem&gt; phone:PivotItem x:Name="GooglePivot" Header="Google"&gt; &lt;ListBox x:Name="GooglePOIList" ItemsSource="{Binding GooglePOICollection}" HorizontalAlignment="Left" Height="441" Width="436" SelectedItem="{Binding SelectedPickupPOI, Mode=TwoWay}" ItemTemplate="{StaticResource POIItemTemplate}" /&gt; &lt;/phone:PivotItem&gt; &lt;/StackPanel&gt; &lt;/phone:Pivot&gt; </code></pre> <p>In the viewmodel</p> <pre><code>public ObservableCollection&lt;PointOfInterest&gt; GooglePOICollection { get; private set; } public PointOfInterest SelectedPickupPOI { get { return _selectedPickupPOI; } set { _selectedPickupPOI = value; NotifyPropertyChanged("SelectedPickupPOI"); } } public PointOfInterestViewModel() { this.GooglePOICollection = = new ObservableCollection&lt;PointOfInterest&gt;(); this.SelectedPickupPOI = new PointOfInterest(); } public event PropertyChangedEventHandler PropertyChanged; protected void NotifyPropertyChanged(String propertyName) { PropertyChangedEventHandler handler = PropertyChanged; if (null != handler) { handler(this, new PropertyChangedEventArgs(propertyName)); } } </code></pre> <p>My PointOfInterest Models</p> <pre><code>public abstract class PointOfInterest : INotifyPropertyChanged { public abstract string id { get; set; } public abstract string label { get; set; } } public class GooglePOI : PointOfInterest { private string _label; public override string label { get { return _label; } set { _label = value; NotifyPropertyChanged("label"); } } } </code></pre> <p><strong>Update</strong> so I found out that if I do <code>_selectedPickupPOI.label = value.label;</code> it will update the view correctly. What am I doing wrong?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload