views:

31

answers:

1

I'm working on a complex application, and I'm having an issue with a listbox not being bounded by the window height. Here's a simplified version of what it looks like. How would I get this listbox to correctly be bounded by the window? Right now, the bottom scroll button is off the screen and cannot be seen until the window is big enough to fit the entire listbox. I need to find a solution that makes the listbox always bounded because I have to implement zooming via a ScaleTransform.

<Grid>        
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="300" />
        <ColumnDefinition/>
    </Grid.ColumnDefinitions>
        <Grid Name="stack">
            <Grid.LayoutTransform>
                <ScaleTransform
                 ScaleX="{Binding ElementName=slider, Path=Value}" 
                 ScaleY="{Binding ElementName=slider, Path=Value}" />
            </Grid.LayoutTransform>
            <WrapPanel HorizontalAlignment="Left">
                <Expander IsExpanded="False" Width="300">hey</Expander>
                <Expander IsExpanded="True"  VerticalAlignment="Stretch" ClipToBounds="True">
                    <Grid>                            
                        <ListBox >                            
                            <Button>hey</Button>
                            <!-- just add a lot more of these to see the problem -->
                            <Button>hey</Button>
                         </ListBox>
                    </Grid>
                </Expander>
            </WrapPanel>

        </Grid>
    <Slider Grid.Column="1" Name="slider" Minimum="1" Maximum="4" Value="1" />

</Grid>
+1  A: 

Hi

try the following code:

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="*" />
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>
    <Border Grid.Row="0">
        <Grid Name="stack">
            <Grid.LayoutTransform>
                <ScaleTransform ScaleX="{Binding ElementName=slider, Path=Value}"
                                ScaleY="{Binding ElementName=slider, Path=Value}" />
            </Grid.LayoutTransform>
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <Border Grid.Row="0">
                    <Expander IsExpanded="False"
                              Width="300">hey</Expander>
                </Border>
                <Border Grid.Row="1">
                    <Expander IsExpanded="True"
                              VerticalAlignment="Stretch"
                              ClipToBounds="True">
                        <Grid>
                            <ListBox>
                                <Button>hey</Button>
                                <Button>hey</Button>
                                <Button>hey</Button>
                                <Button>hey</Button>
                                <Button>hey</Button>
                                <Button>hey</Button>
                                <!-- just add a lot more of these to see the problem -->
                                <Button>hey</Button>
                            </ListBox>
                        </Grid>
                    </Expander>
                </Border>
            </Grid>
        </Grid>
    </Border>
    <Border Grid.Row="1">
        <Slider Name="slider"
                Minimum="1"
                Maximum="4"
                Value="1" />
    </Border>
</Grid>
decyclone
This does just what I wanted. Thanks!
wangburger