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. Vertical text in WPF grid

Vertical text in WPF grid

Scheduled Pinned Locked Moved WPF
csscsharpwpfhelp
4 Posts 3 Posters 0 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.
  • K Offline
    K Offline
    kalberts
    wrote on last edited by
    #1

    I am making a table, using a grid, with one large left column, and to the right, four (or possibly more) check boxes / radio buttons, each in a quite narrow grid column. There is not enough room to label each of the CBs/RBs on every line, so I put the label in the top row, rotated 270 degrees as a vertical text, in a tall (100 units) but narrow (27 units) cell, just enough to hold the longest label. My problem is that WPF appearently clips the label to the edges of the grid cell before rotating the contents, so in my first attempt, the label was clipped at 27 units while it was horizontal, and then this less-that-a-third of the label was rotated to vertical position. I discovered that I could use Grid.ColumnSpan="4" to give the labels enough horizontal space to be drawn in full before rotating. That works only if three extra columns exist, and that holds true only for the first radio button. So I have to place all four of them in column 1 (spanning cols 1-4), and then translate them horizontally to appear visually over their intended columns. This is ugly, messy, inflexible and most certainly not something I would like to maintain in the future, with columns added, widths/heights adjusted, labels changed...:

    L R 2 Replies Last reply
    0
    • K kalberts

      I am making a table, using a grid, with one large left column, and to the right, four (or possibly more) check boxes / radio buttons, each in a quite narrow grid column. There is not enough room to label each of the CBs/RBs on every line, so I put the label in the top row, rotated 270 degrees as a vertical text, in a tall (100 units) but narrow (27 units) cell, just enough to hold the longest label. My problem is that WPF appearently clips the label to the edges of the grid cell before rotating the contents, so in my first attempt, the label was clipped at 27 units while it was horizontal, and then this less-that-a-third of the label was rotated to vertical position. I discovered that I could use Grid.ColumnSpan="4" to give the labels enough horizontal space to be drawn in full before rotating. That works only if three extra columns exist, and that holds true only for the first radio button. So I have to place all four of them in column 1 (spanning cols 1-4), and then translate them horizontally to appear visually over their intended columns. This is ugly, messy, inflexible and most certainly not something I would like to maintain in the future, with columns added, widths/heights adjusted, labels changed...:

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      There's few good reasons to use a Label over a TextBlock. You could try rotating a StackPanel with Labels.

              Slett permanent
              Hopp over
              Legg inn i SiKo
              Kopier til kildedisk
      

      It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food

      1 Reply Last reply
      0
      • K kalberts

        I am making a table, using a grid, with one large left column, and to the right, four (or possibly more) check boxes / radio buttons, each in a quite narrow grid column. There is not enough room to label each of the CBs/RBs on every line, so I put the label in the top row, rotated 270 degrees as a vertical text, in a tall (100 units) but narrow (27 units) cell, just enough to hold the longest label. My problem is that WPF appearently clips the label to the edges of the grid cell before rotating the contents, so in my first attempt, the label was clipped at 27 units while it was horizontal, and then this less-that-a-third of the label was rotated to vertical position. I discovered that I could use Grid.ColumnSpan="4" to give the labels enough horizontal space to be drawn in full before rotating. That works only if three extra columns exist, and that holds true only for the first radio button. So I have to place all four of them in column 1 (spanning cols 1-4), and then translate them horizontally to appear visually over their intended columns. This is ugly, messy, inflexible and most certainly not something I would like to maintain in the future, with columns added, widths/heights adjusted, labels changed...:

        R Offline
        R Offline
        Richard Deeming
        wrote on last edited by
        #3

        That markup looks OK to me in Kaxaml[^]. Perhaps you need to use a layout transform instead of a render transform? LayoutTransform vs. RenderTransform - What's the Difference?[^]


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        K 1 Reply Last reply
        0
        • R Richard Deeming

          That markup looks OK to me in Kaxaml[^]. Perhaps you need to use a layout transform instead of a render transform? LayoutTransform vs. RenderTransform - What's the Difference?[^]


          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

          K Offline
          K Offline
          kalberts
          wrote on last edited by
          #4

          Aaah - thanks a lot! I hadn't leaned the difference between LayoutTransform and RenderTransform. Although LayoutTransform is mentioned in my XAML textbook, it isn't illustrated in an XAML example, so I hadn't grasped the difference between the two concepts. LayoutTransfor gives me code that looks a lot more like I want it, a lot more direct and maintaninable. (I still think XAML often requires an extreme amount of red tape to do fairly simple things. That is an inherent "quality" of XAML, not of transforms in particular, but it certainly is clearly illustrated in transforms!)

          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