Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. WPF Anchor

WPF Anchor

Scheduled Pinned Locked Moved WPF
helptutorialcsharpwpfquestion
3 Posts 2 Posters 9 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    Yoyosch
    wrote on last edited by
    #1

    There is no anchor property in WPF, yet there are VerticalAlignment and HorizontalAlignment which do simply the same. But there is one problem: Suppose that I have an Image control with some png image loaded. When I put this control in the center region of my form and set both Vertical and Horizontal Alignments to STRECH, everything works fine. But when I move this Image towards form`s edges - for example towards top, the VerticalAlignment changes from STRECH to TOP. When I try to change VerticalAlignment back to STRECH, the Image control automatically moves to center region of the form. How to enable streching in both directions while an element is near the edges of the form? Thank you for any help in advance

    J 1 Reply Last reply
    0
    • Y Yoyosch

      There is no anchor property in WPF, yet there are VerticalAlignment and HorizontalAlignment which do simply the same. But there is one problem: Suppose that I have an Image control with some png image loaded. When I put this control in the center region of my form and set both Vertical and Horizontal Alignments to STRECH, everything works fine. But when I move this Image towards form`s edges - for example towards top, the VerticalAlignment changes from STRECH to TOP. When I try to change VerticalAlignment back to STRECH, the Image control automatically moves to center region of the form. How to enable streching in both directions while an element is near the edges of the form? Thank you for any help in advance

      J Offline
      J Offline
      jesarg
      wrote on last edited by
      #2

      Moving an image in the designer can sometimes change its anchoring automatically, which can be really annoying. However, you can, after moving the image in the designer, directly change its anchoring in the designer, too. If you select the image, then each of the 4 sides of the image will have either an empty circle or an anchor bar, depending on whether or not the image is anchored on that side or not. Clicking the empty circle will change it to an anchor bar, and clicking the anchor bar will turn it to an empty circle.

      Y 1 Reply Last reply
      0
      • J jesarg

        Moving an image in the designer can sometimes change its anchoring automatically, which can be really annoying. However, you can, after moving the image in the designer, directly change its anchoring in the designer, too. If you select the image, then each of the 4 sides of the image will have either an empty circle or an anchor bar, depending on whether or not the image is anchored on that side or not. Clicking the empty circle will change it to an anchor bar, and clicking the anchor bar will turn it to an empty circle.

        Y Offline
        Y Offline
        Yoyosch
        wrote on last edited by
        #3

        Thanks a lot

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups