Friday, March 6, 2009

Elements - ListBox, ScrollViewer

ListBox



<ListBox Width="100" Height="100" Background="White">
<ListBox.Items>
<ListBoxItem><TextBlock Text="One"/></ListBoxItem>
<ListBoxItem><TextBlock Text="Two"/></ListBoxItem>
<ListBoxItem><TextBlock Text="Three"/></ListBoxItem>
<ListBoxItem><TextBlock Text="Four"/></ListBoxItem>
</ListBox.Items>
</ListBox>


ListBox allows you to display lists of ...whatever you want. Just add extra ListBoxItems as needed.


ScrollViewer



<ScrollViewer Canvas.Left="10" Canvas.Top="10" Width="200" Height="200" HorizontalScrollBarVisibility="Auto">
<Grid Background="White" Height="250" Width="250">
<Grid.ColumnDefinitions><ColumnDefinition/><ColumnDefinition/></Grid.ColumnDefinitions>
<Grid.RowDefinitions><RowDefinition/><RowDefinition/></Grid.RowDefinitions>

<Border Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Background="#ffffff">
<TextBlock>(0,0)</TextBlock></Border>
<Border Grid.Row="1" Grid.Column="0" Background="#C3D9FF">
<TextBlock>(1,0)</TextBlock></Border>
<Border Grid.Row="1" Grid.Column="1" Background="#3D81EE">
<TextBlock>(1,1)</TextBlock></Border>
</Grid>
</ScrollViewer>

ScrollViewer allows you to add scroll bars to an element that is too large to display in your application. In the example above, the user is able to scroll around the Grid.

No comments:

Post a Comment