I have some control like
<ListBox ItemsSource="{Binding tests, UpdateSourceTrigger=PropertyChanged}"
ItemTemplate="{StaticResource TestTemplate}" />
When user cliked on some element of the ListBox I needed to get data element of this ListBoxItem element in other control and propagate it with data template of other element. How do it properly? Example:
Source:
<ListBox ItemsSource="{Binding tests, UpdateSourceTrigger=PropertyChanged}"
ItemTemplate="{StaticResource TestTemplate}" />
Target:
<TextBlock Text="{Binding Path=name}" />
Where Text in TextBox bind on same data element of selected ListBox item
UPDATE:
How make some control whose content bind to SelectedItem and described by static data template like this:
<DataTemplate x:Key="TestTemplate">
<TextBlock Text="{Binding Path=name}"/>
</DataTemplate>
Resolve with:
<ContentPresenter
HorizontalAlignment="Stretch"
Content="{Binding ElementName=tests_flat, Path=SelectedItem}"
ContentTemplate="{StaticResource TestInfoTemplate}">
</ContentPresenter>
Source
Target