I have a listbox control where items are added using a user control having a textblock and image.
<UserControl
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"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
d:DesignHeight="52" d:DesignWidth="480">
<Grid x:Name="LayoutRoot" Background="{StaticResource PhoneChromeBrush}">
<TextBlock Height="30" HorizontalAlignment="Left" Margin="12,10,0,0" Name="Index_itemtext" Text="" VerticalAlignment="Top" Width="145" />
<Image Height="34" HorizontalAlignment="Right" Margin="0,6,55,0" Source="blue_triangle.png" Name="IndexList_itemImage" Stretch="Uniform" VerticalAlignment="Top" Width="66" />
<Line Height="10" HorizontalAlignment="Left" Margin="0,38,0,0" Name="seperator_line" Stroke="White" StrokeThickness="2" VerticalAlignment="Top" Width="480" Stretch="Fill" Fill="#FFF5E9E9" />
</Grid>
And the list box xaml:
<ListBox Name="Index_list" ScrollViewer.VerticalScrollBarVisibility="Visible"
VerticalContentAlignment="Top" SelectionChanged="on_selection"
Margin="0,78,0,0">
</ListBox>
Now when i add the items to the list ,the vertical scroll does not go till the last item i.e. it comes back to first row which stops from last item selection:
for (int i = 0; i < gridSize; i++)
{
listbox_item list_item = new listbox_item();
list_item.Index_itemtext.FontSize = 25;
list_item.Index_itemtext.Text = index[i];
list_item.IndexList_itemImage.Source = new BitmapImage(new Uri("some.png", UriKind.Relative));
list_item.seperator_line.StrokeThickness = 5;
list_item.Margin = new Thickness(0, 0, 0, 5);
Index_list.Items.Add(list_item);
}
Also the list row does not occupy the width of device in landscape mode,whereas the requirement is that the row item widens as the device width changes.Can someone help with these problems?