开发者

autosizing listbox in Silverlight

I'm doing something that seems like it should be pretty easy, but I'm not getting the results that I want. Maybe someone can give me a hint...

Suppose I have a Silverlight user control. I have a Grid, and 2 row definitions. The top row is going to display search results in a ListBox. I have an item templ开发者_JAVA百科ate assigned to the listbox.

The bottom row contains some controls.

What I want:

  • The bottom row should be a fixed height, and I do not want for it to scroll off of the screen.
  • The top row (and the list box) should "squish" vertically so that it always uses all of the space available minus the space used by the bottom row.
  • So, if the user resizes their browser window, the listbox will grow and shrink vertically.
  • If the listbox cannot display all of its results on one screen, I want it to display a scrollbar.

Here's what I have so far:

  • The listbox and row will grow and shrink dynamically.
  • However, If their are too many results for the listbox to display, it just grows vertically. It will push my bottom grid row right off of the screen.

Here are my row definitions:


        <Grid.RowDefinitions>
            <RowDefinition MinHeight="350" Height="*"/>
            <RowDefinition Height="175"/>
        </Grid.RowDefinitions>

Here's my listbox


<ListBox 
    ScrollViewer.VerticalScrollBarVisibility="Auto" 
    SelectionMode="Single" 
    SelectedItem="{Binding SelectedItem, Mode=TwoWay}" 
    ItemsSource="{Binding View}" 
    ItemTemplate="{StaticResource SearchResultItemTemplate}" 
    Grid.Row="0" />

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜