locked
How do I make a border expand with the page's resizing? RRS feed

  • Question

  • I've got a border, around a user control I've written, which I'm trying to use as a means of making the WPF page it gets positioned over, dimmed.  (i.e.: I dim the page underneath the user control using the border associated with the user control).  However, I've noticed that if the user resizes the WPF application, then the border doesn't resize.  I'd like it to do so automatically.  How do I do that?

    Here's the XAML which surrounds my user control:

    <Border Name="theShadowbox" VerticalAlignment="Center" HorizontalAlignment="Center" Background="Black"
    				Opacity="0.50" Width="378" Height="362" Visibility="Collapsed" Panel.ZIndex="10">
    	<local:UserControlTest x:Name="ucMyControl" WeAreDone="ucMyControl_WeAreDone" Panel.ZIndex="12" />
    </Border>
    

    Rod
    Thursday, June 24, 2010 3:23 PM

Answers

  • Use margin instead of an explicit height/width. If you are inside a container such a a grid, setting it to stretch and using margins will allow it to expand.
    • Marked as answer by Rod at Work Thursday, June 24, 2010 8:36 PM
    Thursday, June 24, 2010 5:53 PM
    Moderator

All replies

  • Use margin instead of an explicit height/width. If you are inside a container such a a grid, setting it to stretch and using margins will allow it to expand.
    • Marked as answer by Rod at Work Thursday, June 24, 2010 8:36 PM
    Thursday, June 24, 2010 5:53 PM
    Moderator
  • I've got some follow-up questions, I'm afraid.

    To what do I apply the margins?  To the border, or to my user control?

    And I'm sorry to ask such a fundamental question, but how do I "...[set] it to stretch and using margins ..."?

     


    Rod
    Thursday, June 24, 2010 8:27 PM
  • OK, never mind, I think I figured it out.  Now I've got another question, but I'll start another topic for that.

     


    Rod
    Thursday, June 24, 2010 8:36 PM