Software & Finance





Visual Studio.NET WPF - List Box Adding Items at design time





Adding a list box item is an easy task. You can do it at design time itself using ListBoxItem. Look at the xaml code below:

 

<Window x:Class="ListBoxAddItem.MainWindow"

        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

        Title="MainWindow" Height="200" Width="200">

    <Grid>

        <ListBox Height="107" HorizontalAlignment="Center" Margin="5,30,5,0" Name="listBox1" VerticalAlignment="Top" Width="150">

            <ListBoxItem Content="India"> </ListBoxItem>

            <ListBoxItem Content="USA"></ListBoxItem>

            <ListBoxItem Content="UK"></ListBoxItem>

            <ListBoxItem Content="Malaysia"></ListBoxItem>

            <ListBoxItem Content="Singapore"></ListBoxItem>

        </ListBox>

    </Grid>

</Window>