Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Allow WPF Grid cell content to expand outside of the grid cell?

I have a Grid in my WPF window. When a particular button is pressed, I want a control in one of the Grid cells to expand downward to double its original size. When this happens, the control is clipped to the visual bounds of the containing cell. However, I need all of the content to be visible, over the top of the cell below. I tried setting Panel.ZIndex to a high value, to no avail. I basically need to emulate the functionality of "overflow:visible" in CSS. Is this possible in WPF/Xaml?

like image 510
Nick W. Avatar asked Jun 14 '11 01:06

Nick W.


1 Answers

Set the ClipToBounds property of the control within the cell to False and then wrap the cell's content in a Canvas. The Canvas is a guaranteed break out of bounds, not all controls do (such as Buttons).

Example:

<Canvas Grid.Row="5" Grid.Column="3">
    <TextBlock Text="Long text here" ClipToBounds="False">
</Canvas>
like image 148
dotancohen Avatar answered Sep 22 '22 14:09

dotancohen