Search code examples
wpfxaml

Docking and Anchoring is missing


I did not find the control's property called dock and anchor. If it is not there then how can I have the flavor of dock and anchor property of every control? How could I set a controls dock property to Top?


Solution

  • 'Docking' in WPF can be done by Setting the HorizontalAllignment and the VerticalAllignment properties of a child control.

    An alternative is nesting the control in a DockPanel and setting the DockPanel.Dock to e.g. Top on the control.l:

    <DockPanel>
        <TextBlock DockPanel.Dock="Top" />
    </DockPanel>
    

    'Anchoring' in WPF can be done by setting the Margin on the child and/or the Padding on the container.