Listbox extending off the page

I have a listbox inside of a stack panel inside of a border in a silverlight application and when ever I add anything to the listbox it increases in height so the scrollbar is never used and it extends beyond the boundaries of the border element. I have tried explicitly setting the height attribute of the listbox, the border and the stack panel and it still goes beyond this.

Here is my code:

<Border x:Name="articlePane">
                <StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Top">
                        <Button Content="Latest" MouseEnter="HandleRollInAnimation" MouseLeave="HandleRollOutAnimation" />
                        <Button Content="Pending" MouseEnter="HandleRollInAnimation" MouseLeave="HandleRollOutAnimation" />
                        <Button Content="Done" MouseEnter="HandleRollInAnimation" MouseLeave="HandleRollOutAnimation" />
                    </StackPanel>
                    <ListBox x:Name="articleList" Margin="5" Background="Transparent" ItemsSource="{Binding}" 
                             ScrollViewer.VerticalScrollBarVisibility="Visible">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Vertical" VerticalAlignment="Top" HorizontalAlignment="Center">
                                    <Image x:Name="articleImage" />
                                    <TextBlock x:Name="articleTitle" Text="{Binding Path=Title}" FontSize="18" FontWeight="Bold"
                                               Margin="5"/>
                                    <TextBlock x:Name="articleDate" Text="{Binding Path=Date}" FontSize="14" Foreground="Gray"
                                               Margin="5"/>
                                </StackPanel>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                </StackPanel>
            </Border>

Answers


I have a feeling that the StackPanel just keeps on adding height forever. I think in this instance you'd be better off with a Grid layout within your Border. Put the Button StackPanel in one height defined row, and the ListBox in an autosizing * height row. This way Grid will stick within the confines of your form.


Need Your Help

simple financial rate function in javascript

javascript function financial rate

I'm looking for a simple javascript financial RATE function, and I found this one. But it seems too difficult to understand. I want to simplify this function, and I need your help.

What is the ideal way to send a date parameter over a GET request in Play Framework?

java javascript datetime playframework get

I am new to Play Framework. I am able to send simple data types like string, integer etc directly via the request and access them in the Back end Java method.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.