Managing a listbox in the code behind c#

Havet Thibault 1 Reputation point
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

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,689 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,406 questions
{count} votes