Managing a listbox in the code behind c#

Anonymous
2021-08-11T09:18:29.27+00:00

Hi, I have this ListBox

<ListBox x:Name="LBMatch" Grid.Column="0" Grid.Row="3" Margin="10,8,10.2,21.4" ItemsSource="{Binding}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel x:Name="SPHorizontal" Orientation="Horizontal">
<Label x:Name="LP1VSP2"/>
<Label x:Name="LDateAffrontement"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>

But I want to get the reference of the label "LP1VSP2" in the code behind in order to set the databinding (I know how to proceed with the dataconverter, the binding, etc), but I don't how to do that : The listbox reference doesn't contain a property "Itemtemplate" nor a property "DataTemplate".

Thanks for the help in advance

Developer technologies | Windows Presentation Foundation
Developer technologies | C#
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.