Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 89864

Every update of ObservableCollection should run the Converter on ItemSource. How do I get it?

$
0
0

Hello,
I have a ListView. The ItemSource is bind to a ObservableCollection.

ListView:

<ListView xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="..."
             xmlns:util="..."
             ItemsSource="{Binding Items, Converter={StaticResource ManipulateItems}}"
             ItemTapped="DataListOverviewOnItemTapped">

<ListView.Resources>
    <ResourceDictionary>
      <util:ItemsConverter x:Key="ManipulateItems" />
    </ResourceDictionary>
  </ListView.Resources>
(...)

ObservableCollection:

public ObservableCollection<DetailInfoItem> Items
        {
            get { return _items ?? (_items = new ObservableCollection<Item>()); }
        }

ItemsConverter:

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            System.Diagnostics.Debug.WriteLine("Converted!");
}

This is working perfect for first time.

But when I update the ObservableCollection:

Items.Clear();
Items.Add(..)

The updated Items will displayed, but without converting. The Converter is not running on update of ObservableCollection. I don't uderstand why.

How can I fix it?

Thanks.


Viewing all articles
Browse latest Browse all 89864

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>