Reuse template for different listbox items
-
Hello, I have a ListBox which is bound to an ObservableCollection, using some (complex) ItemTemplate to display the data. It is guaranteed that there is a fixed number of items within the ItemsSource. Every time, the ObservableCollection changes (e.g., an item is replaced), a new ItemTemplate is generated. Can I somehow avoid this and instead reuse the existing template object and simply bind this to the new data? My idea was to use a dynamic resource:
...
But how can I, in this case, set the Properties of the chart (e.g. the DataContext, or the Grid.Row as the object is embedded within a Grid)? A second problem is: If I have n elements within the ObservableCollection, I need n chart objects. How can I make sure to use a different chart object for each observable? Alex