开发者

WPF Create a slide out panel

I don't know how this works technically but my requirement is as follows. I have a DataGrid and to input data into the DataGrid, I want a panel at the bottom of the DataGrid that slides out on a button click showing input options. Except, as the panel slide开发者_Go百科s out, the DataGrid has to resize vertically as well. Can someone throw some light on how I can implement this?


You should be able to use a StackPanel with 2 children, your grid and your panel. Set the initial height of your panel to 0. Once the button is clicked, set the height to whatever you need it to be (e.g., MyPanel.Height = 20). You might want to wrap the grid in a ScrollViewer in case that is needed.

<StackPanel Orientation="Vertical">
    <ScrollViewer Height="Auto" VerticalAlignment="Stretch">
        <Grid Height="*" VerticalAlignment="Stretch" />
    </ScrollViewer>
    <ContentControl x:Name="MyPanel" Height="0" />
</StackPanel>

You might need to experiment with VerticalAlignment and Height="Auto" or Height="0" to get the layout you want.


You can use Expander. Please look at the following code snippet.

 <DockPanel>
        <Expander DockPanel.Dock="Bottom">
            <StackPanel>
                <TextBlock Height="25"></TextBlock>
                <TextBlock Height="25"></TextBlock>
                <TextBlock Height="25"></TextBlock>

            </StackPanel>
        </Expander>
        <Border BorderBrush="LightGreen" BorderThickness="2">
            <DataGrid/>
        </Border>
    </DockPanel >
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜