Reputation: 6378
I'm using this code in a XAML page:
<TextBox ItemsSource="{Binding Posters, Converter={StaticResource collectionToFirstElementConverter}, Mode=TwoWay}" />
Posters is an ObsevableCollection and I'm using a converter where takes the collection and gets the first element of it.
As I'm using async procedures, where the textbox receives the object, this one has no elements (Count=0), and calls the converter.
I'm trying to update the textbox everytime the property add new elements, but not calls the converter.
I remember that in Silverlight or WPF, exists SourceTrigger or UpdatePropertyChanged, but in WinRT I can't see this mode.
Upvotes: 0
Views: 1682
Reputation: 17855
The easiest way to achieve that would be to modify your view model containing the Posters
property accordingly. I can see two ways to go about it (both asuming that your view model implements INotifyPropertyChanged
):
Posters.CollectionChanged
and inside it raise INotifyPropertyChanged.PropertyChanged
for Posters
.FirstPoster
returning the value of the first element in Posters
. In the view model add an event handler to Posters.CollectionChanged
and inside it raise INotifyPropertyChanged.PropertyChanged
for FirstPoster
. This way you don't even need the converter.I personally like the second approach better.
Upvotes: 2