I successfully added a listbox with databinding in my xaml:
But i forgot which attribute to use for the items header. My items contain to Textboxes "name", "money earned" and if i add items my items say for example "Mustermann", "300" but i need a headertemplate above the items which says "name" and "money earned" how do i add such a header for the items?
The xaml I already wrote isn't relevant for this question but if you are interested:
<ListBox x:Name="WorkersList" ItemsSource="{Binding}" MaxWidth="480" MaxHeight="400" VerticalAlignment="Top" HorizontalAlignment="Left">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding name}" HorizontalAlignment="Center" Width="100"></TextBlock>
<TextBlock Text="{Binding gehalt}" HorizontalAlignment="Center" Width="100"></TextBlock>
<ToggleSwitch></ToggleSwitch>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
You could use a ListView with a GridView. In each GridViewColumn
, there is a property called Header
.
EDIT:
You could use a ListView
. Apparently there is a ListView.Header
property in W10 apps. Have a look at this. Something like the following could work:
<ListView>
<ListView.Header>
<StackPanel>
<TextBlock Text="Name"/>
<TextBlock Text="Money earned"/>
</StackPanel>
</ListView.Header>
</ListView>