L
L
Linar_Zigangirov2014-08-26 20:54:01
Android
Linar_Zigangirov, 2014-08-26 20:54:01

WPF. How to properly bind multiple ListView located in TabControl to one property?

The page has a TabControl with two tabs, each tab has one ListView. The ItemsSource properties of the ListView items are associated with a single ItemsSource specified in the page resources. When you first view the tabs, both ListViews are filled, i.e. the binding worked, but when re-viewing, only one ListView remains filled, the second one turns out to be empty. Help me to understand! Simplified, it looks like this:

------
<Page.Resources>
 <ItemsSource x:Name="ISource" x:Key="ISource"/>  
</Page.Resources>  

--------

<TabControl>
  <TabItem>
<ListView ItemsSource = "{Binding ItemsSource, ElementName ISource}" />
</TabItem>
   <TabItem>
<ListView ItemsSource = "{Binding ItemsSource, ElementName ISource}" />
</TabItem>
</TabControl>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Papin, 2014-12-06
@i_light

The Resources section declares the control's static resources. They need to be used like this:
x:Name is not needed in this case, only x:Key.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question