[RESOLVED] Change which item resizes in DockPanel
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: [RESOLVED] Change which item resizes in DockPanel

Hybrid View

  1. #1
    Join Date
    Mar 2009
    Posts
    5

    [RESOLVED] Change which item resizes in DockPanel

    I have a DockPanel with two items in it, one docked to the left, and one docked to the right. By default, when the DockPanel is resized, the item on the right resizes to fill the space, whereas the left item stays the same. How do I get it so that the left item resizes and the right item stays the same.

    Example:

    <DockPanel>
    <Button Name="button1" >ButtonA</Button>
    <Button Name="button2" DockPanel.Dock="Right">ButtonB</Button>
    </DockPanel>

    I want button1 to resize when the DockPanel resizes instead of button2.

    Edit: I forgot to mention that the reason I'm using a DockPanel in the first place (as opposed to a Grid or some other panel) is that I want the ability to set the visibility of button2 to "collapsed" and then have button1 fill to take up the whole area. In my actual implementation, what I'm actually trying to do is have a panel that takes up the whole window. When a button is clicked (a "more options" type of thing), a second panel appears, and the two panels share the area in the window. I'd be open to any method of getting this done; I just thought a DockPanel made the most sense.

    Eric
    Last edited by Eric H; March 18th, 2009 at 02:49 PM.

  2. #2
    Join Date
    Mar 2009
    Posts
    5

    Re: Change which item resizes in DockPanel

    Solved.

    The solution is to simply add the controls to the DockPanel in the reverse order. Using the previous example, it would be like this:

    <DockPanel>
    <Button Name="button2" DockPanel.Dock="Right">ButtonB</Button>
    <Button Name="button1" >ButtonA</Button>
    </DockPanel>

    Then, button1 will resize instead of button2.

    Eric

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center