-1

Is it possible to add a stackpanel inside a rectangle. I need a custom wpf window that has rounded corners. Best way to achieve it for me was to add a rectangle content into a window and make window's background transparent. Now I need two stackpanels but how can I place it inside a rectangle?

Josh Crozier
  • 233,099
  • 56
  • 391
  • 304
bilgestackoverflow
  • 329
  • 1
  • 6
  • 24

1 Answers1

5

use a Border control instead of a Rectangle, a Border can have content, the Stackpanel in your case.

Another possibility would be to use a Grid, where you put the Rectangle and the Stackpanel into the same cell:

<Grid>
  <Rectangle .../>
  <StackPanel>...</StackPanel>
</Grid>
H.B.
  • 166,899
  • 29
  • 327
  • 400
thumbmunkeys
  • 20,606
  • 8
  • 62
  • 110
  • Thanks, I will try your suggestions. – bilgestackoverflow Feb 12 '12 at 11:38
  • Thanks, Now I can manipulate the StackPanel but not as I expected it to be. I set RadiusX="25" RadiusY="25" properties and my Rectangle is rounded. But the corners' of stackpanel I placed on top of the window is not rounded. How can I attain a stable look? – bilgestackoverflow Feb 12 '12 at 11:57
  • make the stackpanel transparent – thumbmunkeys Feb 12 '12 at 12:00
  • But the problem is that the stackpanel has a different background color than the rectangle. If I make it transparent how can I set a color – bilgestackoverflow Feb 12 '12 at 12:01
  • then add a margin to the stackpanel – thumbmunkeys Feb 12 '12 at 12:02
  • Thanks but I am sorry that I can not achieve it If I send you the design they have asked from me you should have better suggestions. I am new so I take wrong decisions. We can't attach a picture through posts can we? My design will be a custom window. A top menu for close, minimize, maximize buttons. And another menu or panel at the bottom. Both of the panels have the same background color(gray) and the center of the window has green background. The form will be resizable and so on. The corners are rounded – bilgestackoverflow Feb 12 '12 at 12:17
  • use the border solution, it is better anyway – thumbmunkeys Feb 12 '12 at 12:57