locked
Dock Fill WPF (Manjusha) - 12/12/2007 11:04 AM PST RRS feed

  • Question

  • By: Manjusha


    Any idea why System.Windows.Controls.Dock.Fill disappeared from the WPF? How 
    can I simulate it? Dockpanel has only Left,Top,Bottom and Right. How can we 
    get the control to fill the entire screen ?
    Suppose I have a TabControl, how can I set its propert to fill the screen ??
    
    Thanks
    Thursday, February 21, 2008 10:18 PM

All replies

  • By: Corrado Cavalli [MVP]

    If you just want a control to fill its container select the control, right 
    click it and select AutoSize->Fill
    
    -- 
    Corrado Cavalli [Microsoft .NET MVP-MCP]
    UGIdotNET - http://www.ugidotnet.org
    Weblog: http://blogs.ugidotnet.org/corrado/ 
    
    
    Friday, February 22, 2008 10:27 PM
  • By: Brennon Williams

    Howdy,
    
    Following on from Corrado's advice,
    
    There is also a property on the doc panel called LastChildFill which is set 
    to false by default. Check that an the last (or only) child you add will fill 
    the dock panel.
    
    If you are looking to fill a grid panel with a tab control, you only need 
    set its Width and Height properties to Auto, and it Horizontal and Vertical 
    Alignment to Stretch and you should achieve the same effect.
    
    Cheers
    -- 
    Want to learn how to use Blend and visual studio?
    
    http://www.learnexpressionstudio.com
    http://www.expressionblend.com
    http://www.x-coders.com
    
    
    "Corrado Cavalli [MVP]" wrote:
    
    > If you just want a control to fill its container select the control, right 
    > click it and select AutoSize->Fill
    > 
    > -- 
    > Corrado Cavalli [Microsoft .NET MVP-MCP]
    > UGIdotNET - http://www.ugidotnet.org
    > Weblog: http://blogs.ugidotnet.org/corrado/ 
    > 
    > 
    Friday, February 22, 2008 10:29 PM
  • By: Tor Langlo

    Just to clarify a bit, using Object|Auto Size|Fill on Blend's menu causes 
    Blend to set a hardcoded height and width on the element. This width and 
    height corresponds to the current width and height of the parent panel 
    (DockPanel), irregardless of what's already docked in it. If the parent 
    panel later is resized the child panel will **not** be auto-resized to yet 
    again fill the space.
    
    As Brennan said, the solution is to use the LastChildFill property (which 
    actually defaults to true). When LastChildFill is true, the last declared 
    child element will automatically fill the remaining available area of the 
    parent DockPanel. Hint, it might be counter intuitive, but if you needed 
    topmost child element to auto-size, it still needs to be declared last 
    among the parent's child elements.
    
    Tor Langlo
    
    Friday, February 22, 2008 10:30 PM
  • By: Brennon Williams

    Howdy Tor,
    
    I know the msdn documentation states that the property is true by default, 
    but I think it is wrong.
    
    I have just launched Blend 1 RTM, default is false, launched Blend 2 dec 
    preview and several other builds and everytime it is false by default.
    
    We could be both wrong and it could now be last value set, but I cant get 
    that either.
    
    I kinda think if it was true by default, Man would have had his child fill 
    the dock in the first place, and this thread wouldnt exist... ;-)
    
    
    Cheers Tor.
    -- 
    Want to learn how to use Blend and visual studio?
    
    http://www.learnexpressionstudio.com
    http://www.expressionblend.com
    http://www.x-coders.com
    
    
    "Tor Langlo" wrote:
    
    > Just to clarify a bit, using Object|Auto Size|Fill on Blend's menu causes 
    > Blend to set a hardcoded height and width on the element. This width and 
    > height corresponds to the current width and height of the parent panel 
    > (DockPanel), irregardless of what's already docked in it. If the parent 
    > panel later is resized the child panel will **not** be auto-resized to yet 
    > again fill the space.
    > 
    > As Brennan said, the solution is to use the LastChildFill property (which 
    > actually defaults to true). When LastChildFill is true, the last declared 
    > child element will automatically fill the remaining available area of the 
    > parent DockPanel. Hint, it might be counter intuitive, but if you needed 
    > topmost child element to auto-size, it still needs to be declared last 
    > among the parent's child elements.
    > 
    > Tor Langlo
    > 
    Friday, February 22, 2008 10:31 PM
  • By: Unni Ravindranathan (MS)

    I have not read the entire thread but: Expression Blend, in its UI, does not 
    use DockPanel. Pretty much everything can be done using Grid, which is far 
    more powerful. Thought I would pass this around :).
    
    Thanks,
    -Unni
    
    "Brennon Williams" <BrennonWilliams@discussions.microsoft.com> wrote in 
    message news:442977C3-0F3B-4FEB-A2FF-87FE92160041@microsoft.com...
    > Howdy Tor,
    >
    > I know the msdn documentation states that the property is true by default,
    > but I think it is wrong.
    >
    > I have just launched Blend 1 RTM, default is false, launched Blend 2 dec
    > preview and several other builds and everytime it is false by default.
    >
    > We could be both wrong and it could now be last value set, but I cant get
    > that either.
    >
    > I kinda think if it was true by default, Man would have had his child fill
    > the dock in the first place, and this thread wouldnt exist... ;-)
    >
    >
    > Cheers Tor.
    > -- 
    > Want to learn how to use Blend and visual studio?
    >
    > http://www.learnexpressionstudio.com
    > http://www.expressionblend.com
    > http://www.x-coders.com
    >
    >
    > "Tor Langlo" wrote:
    >
    >> Just to clarify a bit, using Object|Auto Size|Fill on Blend's menu causes
    >> Blend to set a hardcoded height and width on the element. This width and
    >> height corresponds to the current width and height of the parent panel
    >> (DockPanel), irregardless of what's already docked in it. If the parent
    >> panel later is resized the child panel will **not** be auto-resized to 
    >> yet
    >> again fill the space.
    >>
    >> As Brennan said, the solution is to use the LastChildFill property (which
    >> actually defaults to true). When LastChildFill is true, the last declared
    >> child element will automatically fill the remaining available area of the
    >> parent DockPanel. Hint, it might be counter intuitive, but if you needed
    >> topmost child element to auto-size, it still needs to be declared last
    >> among the parent's child elements.
    >>
    >> Tor Langlo
    >> 
    
    Friday, February 22, 2008 10:32 PM
  • By: Brennon Williams

    Howdy Unni,
    
    We were talking about the DockPanel element (not the Blend UI) and its 
    default state, but mainly Manjusha wanted to know how to get a child to fill 
    it instead of just docking.
    
    Cheers
    -- 
    Want to learn how to use Blend and visual studio?
    
    http://www.learnexpressionstudio.com
    http://www.expressionblend.com
    http://www.x-coders.com
    
    
    "Unni Ravindranathan (MS)" wrote:
    
    > I have not read the entire thread but: Expression Blend, in its UI, does not 
    > use DockPanel. Pretty much everything can be done using Grid, which is far 
    > more powerful. Thought I would pass this around :).
    > 
    > Thanks,
    > -Unni
    > 
    > "Brennon Williams" <BrennonWilliams@discussions.microsoft.com> wrote in 
    > message news:442977C3-0F3B-4FEB-A2FF-87FE92160041@microsoft.com...
    > > Howdy Tor,
    > >
    > > I know the msdn documentation states that the property is true by default,
    > > but I think it is wrong.
    > >
    > > I have just launched Blend 1 RTM, default is false, launched Blend 2 dec
    > > preview and several other builds and everytime it is false by default.
    > >
    > > We could be both wrong and it could now be last value set, but I cant get
    > > that either.
    > >
    > > I kinda think if it was true by default, Man would have had his child fill
    > > the dock in the first place, and this thread wouldnt exist... ;-)
    > >
    > >
    > > Cheers Tor.
    > > -- 
    > > Want to learn how to use Blend and visual studio?
    > >
    > > http://www.learnexpressionstudio.com
    > > http://www.expressionblend.com
    > > http://www.x-coders.com
    > >
    > >
    > > "Tor Langlo" wrote:
    > >
    > >> Just to clarify a bit, using Object|Auto Size|Fill on Blend's menu causes
    > >> Blend to set a hardcoded height and width on the element. This width and
    > >> height corresponds to the current width and height of the parent panel
    > >> (DockPanel), irregardless of what's already docked in it. If the parent
    > >> panel later is resized the child panel will **not** be auto-resized to 
    > >> yet
    > >> again fill the space.
    > >>
    > >> As Brennan said, the solution is to use the LastChildFill property (which
    > >> actually defaults to true). When LastChildFill is true, the last declared
    > >> child element will automatically fill the remaining available area of the
    > >> parent DockPanel. Hint, it might be counter intuitive, but if you needed
    > >> topmost child element to auto-size, it still needs to be declared last
    > >> among the parent's child elements.
    > >>
    > >> Tor Langlo
    > >> 
    > 
    Friday, February 22, 2008 10:41 PM
  • By: Tor Langlo

    Hi Brennan,
    
    About LastChildFill, here's what I see in Blend 2, December preview:
    
    If I drop a DockPanel (e.g. by double-clicking it in the pallette), Blend 
    automatically inserts "LastChildFill=False". You could therefore say that 
    this is the "Blend" default.
    
    If I the remove the LastChildFill attribute from the DockPanel element in 
    xaml, then at runtime LastChildFill will be true ("true" is the 
    LastChildFill dependency property's default value in the metadata). You 
    could therefore say that this is the "WPF" default.
    
    Why Blend chooses to insert "LastChildFill=False" on a new element I don't 
    know. I guess a couple of versions into the future Blend will have all the 
    basic features nailed down, and we (at least the developers) will all be 
    focusing on optimizing the xaml code generation. Guys like me which learned 
    xaml before Blend take great care in how the xaml code is organized... :-)
    
    Tor.
    
    Friday, February 22, 2008 10:42 PM
  • By: Corrado Cavalli [MVP]

    > Just to clarify a bit, using Object|Auto Size|Fill on Blend's menu causes
    > Blend to set a hardcoded height and width on the element.
    In some cases you're right (DockPanel, StackPanel) but in others (Grid, the 
    TabControl case) AutoSize-> Fill approach is equivalent (no fixed values 
    written)
    
    
    -- 
    Corrado Cavalli [Microsoft .NET MVP-MCP]
    UGIdotNET - http://www.ugidotnet.org
    Weblog: http://blogs.ugidotnet.org/corrado/ 
    
    
    Friday, February 22, 2008 10:45 PM