Hi,
I"m trying to get my head wrapped around the WPF model.
I have a list box of items. Inside the list box items are string identifiers. This works fine. What I want is to have it so that the identifier from the currently selected item is accessible in my code-behind for the enclosing control.
I have this:
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Width="320">
<Label Content="{Binding Path=ShortName}" Style="{StaticResource ListHeader}"/>
<TextBlock TextWrapping="Wrap" Text="{Binding Path=Description}" Style="{StaticResource ListText}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
And I think I should add something like:
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBoxItem}},Path=IsSelected}" Value="True">
<Setter Property="" TargetName="">
<Setter.Value>
</Setter.Value>
</Setter>
</DataTrigger>
But I'm lost as to how to set-up the setter to set a property that's part of the enclosing control (ie, the outside world). I think I have this backwards somehow?