Use TextBlock as ListBox item : ListBox « UI Controls « Silverlight






Use TextBlock as ListBox item

Use TextBlock as ListBox item
    

<UserControl x:Class='SilverlightApplication3.MainPage'
    xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' 
    xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
    xmlns:d='http://schemas.microsoft.com/expression/blend/2008' 
    xmlns:mc='http://schemas.openxmlformats.org/markup-compatibility/2006' 
    mc:Ignorable='d' 
    d:DesignWidth='640' 
    d:DesignHeight='480'>
    <Canvas  x:Name="LayoutRoot" Background="White">
        <ListBox Canvas.Top="50" Canvas.Left="40" Width="200">
            <ListBox.Items>
                <ListBoxItem>
                    <TextBlock Text="ITEM #1"/>
                </ListBoxItem>
                <ListBoxItem>
                    <TextBlock Text="ITEM #2"/>
                </ListBoxItem>
                <ListBoxItem>
                    <TextBlock Text="ITEM #3"/>
                </ListBoxItem>
                <ListBoxItem>
                    <TextBlock Text="ITEM #4"/>
                </ListBoxItem>
            </ListBox.Items>
        </ListBox>
    </Canvas>
</UserControl>

   
    
    
    
  








Related examples in the same category

1.ListBox data bindingListBox data binding
2.Creating a ListBoxCreating a ListBox
3.Add a simple ListBoxItem, a TextBlock, a StackPanel to ListBox
4.Put Image to ListBoxPut Image to ListBox
5.A ListBox that displays the days of the weekA ListBox that displays the days of the week