Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ListView height inside of a StackPanel - problem...
Message
From
18/06/2008 16:57:39
 
 
To
All
General information
Forum:
ASP.NET
Category:
Windows Presentation Foundation (WPF)
Title:
ListView height inside of a StackPanel - problem...
Miscellaneous
Thread ID:
01325263
Message ID:
01325263
Views:
156
I have a ListView in a StackPanel and when I set the ItemSource property on the ListView it in the code-behind, the height of the ListView becomes taller that StackPanel, and it make the ListView chopped off at the bottom of the StackPanel.

I did not hard-code the height of the ListView, but I thought the default behavior was that the last control in a StackPanel automatically fills the rest of the StackPanel height?

If I hard-code a height in the XAML, it does fine, but I do not want to hard-code height.

What am I missing?
<Window x:Class="wpf2.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="600" Width="300">
    <StackPanel Height="600" VerticalAlignment="Top" >
        <StackPanel Orientation="Horizontal">
            <TextBox x:Name="txtCustomerFilter" Width="100" Margin="5"></TextBox>
            <Button x:Name="ButtonSearch" Width="50" Margin="5" Click="ButtonSearch_Click">Search</Button>
        </StackPanel>
        <ListView Name="lv2" HorizontalContentAlignment="Stretch" ScrollViewer.VerticalScrollBarVisibility="Visible">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <Border Margin="5" BorderThickness="1" BorderBrush="SlateGray" CornerRadius="4">
                        <Grid Margin="3">
                            <Grid.RowDefinitions>
                                <RowDefinition></RowDefinition>
                                <RowDefinition></RowDefinition>
                                <RowDefinition></RowDefinition>
                                <RowDefinition></RowDefinition>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="39"></ColumnDefinition>
                                <ColumnDefinition></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <TextBlock Grid.Row="0" FontWeight="Bold" Text="{Binding Path=custno}"></TextBlock>
                            <TextBlock Grid.Row="1" Text="{Binding Path=company}"></TextBlock>
                            <Label Grid.Column="0" Grid.Row="2" Content="Phone: " HorizontalAlignment="Left"></Label>
                            <TextBlock Grid.Column="1" Grid.Row="2" Text="{Binding Path=phone}" HorizontalAlignment="Left"></TextBlock>
                            <TextBlock Grid.Row="4" Text="{Binding Path=faxno}"></TextBlock>
                        </Grid>
                    </Border>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
</StackPanel>

</Window>
Next
Reply
Map
View

Click here to load this message in the networking platform