0

I have two tabs.

The code of both tabs is in the same XAML file (yes, it must be)

Each tab references the same ObservableCollection

<ItemsControl ItemsSource="{Binding ConnectorItems}">
    <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <Grid />
        </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>
</ItemsControl>

Depending on the tab, the collection is reloaded and contains other data

The problem is that it only displays in the last tab.

I know that this results from logical parents but I am looking for a solution in this situation

If I had a bookmark code in a separate XAML it would not be a problem but I can not use it

programmerJavaPL
  • 496
  • 6
  • 23
  • This [link](https://stackoverflow.com/questions/37201128/binding-itemscontrol-to-observablecollection-extra-generated-item) may help you – Aderbal Farias Apr 02 '19 at 08:44
  • 1
    ConnectorItems should not be a collection of UI elements. It should instead be a collection of data items, and the ItemsControl's ItemTemplate should be a DataTemplate with UI elements that bind to the properties of an individual data item. – Clemens Apr 02 '19 at 08:52
  • @Clemens In simple cases, this should be the case. But here I have a very complicated situation. There are different possibilities, many conditions on which a different appearance of the element depends – programmerJavaPL Apr 02 '19 at 09:00
  • All that is usually done by different DataTemplates for different data item types. Take a look at [Data Templating Overview](https://learn.microsoft.com/en-us/dotnet/framework/wpf/data/data-templating-overview). – Clemens Apr 02 '19 at 09:02

0 Answers0