how to get number of items in listbox

Viewed 88235

In my program i took a listbox, in this listbox I added number of items.

Now I want to know how to get number of listbox items & show number of items in a textbox. when number of items is not fixed.

2 Answers

I would like to present an answer for the people who uses WPF.

<ListBox  ItemsSource="{Binding Path=Parts}">                   
    <ListBox.ItemTemplate>
        <DataTemplate>
            <StackPanel Orientation="Horizontal" >
                <Label Content="{Binding CurrentPart, Mode=OneWay}" />
                <Label Content="{Binding Path=Parts.Count}"                           
            </StackPanel>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>
Related