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. Arrange controls inside a user control in wpf

Arrange controls inside a user control in wpf

Scheduled Pinned Locked Moved WPF
csharpwpfhelpquestion
5 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.
  • D Offline
    D Offline
    dashingsidds
    wrote on last edited by
    #1

    Hi Experts, I have a user control. I am dynamically adding controls to this user control using Children.Add. I want to change their location on some event in code. Like we can do in winform using Location. Is there anything similar to this? Please help! Thanks in advance! Regards, Samar

    P 1 Reply Last reply
    0
    • D dashingsidds

      Hi Experts, I have a user control. I am dynamically adding controls to this user control using Children.Add. I want to change their location on some event in code. Like we can do in winform using Location. Is there anything similar to this? Please help! Thanks in advance! Regards, Samar

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      You could always set the Margin of the control to move/size it. Without knowing what exactly you are trying to achieve, it's hard to add any more detail.

      "WPF has many lovers. It's a veritable porn star!" - Josh Smith

      As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

      My blog | My articles | MoXAML PowerToys | Onyx

      D 1 Reply Last reply
      0
      • P Pete OHanlon

        You could always set the Margin of the control to move/size it. Without knowing what exactly you are trying to achieve, it's hard to add any more detail.

        "WPF has many lovers. It's a veritable porn star!" - Josh Smith

        As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

        My blog | My articles | MoXAML PowerToys | Onyx

        D Offline
        D Offline
        dashingsidds
        wrote on last edited by
        #3

        Hi, I think i was a little too generic in explaining my problem. I will give my current scenario. I am trying to build an MDI in WPF. As you know there is no concept of MDI in WPF but i got a simulated MDI code from codeplex. The link for the same is given here. Now i want to tile the child controls in the mdi either horizontally, vertically or cascade in the way similar to windows MDI like this.LayoutMdi(MdiLayout.TileHorizontal);. Please help! Thanks in advance. Regards, Samar

        B 1 Reply Last reply
        0
        • D dashingsidds

          Hi, I think i was a little too generic in explaining my problem. I will give my current scenario. I am trying to build an MDI in WPF. As you know there is no concept of MDI in WPF but i got a simulated MDI code from codeplex. The link for the same is given here. Now i want to tile the child controls in the mdi either horizontally, vertically or cascade in the way similar to windows MDI like this.LayoutMdi(MdiLayout.TileHorizontal);. Please help! Thanks in advance. Regards, Samar

          B Offline
          B Offline
          BechBej
          wrote on last edited by
          #4

          Did you mean something like this? [code]

          [/code] Try to copy and paste this in a blanc scene, it that what you want then you can also do this in code behind [code]Rectangle rect = new Rectangle { Width = 50, Height = 50, Fill = new SolidColorBrush(Colors.Blue) }; Canvas.SetLeft(rect, 50); Canvas.SetTop(rect,50); [/code]

          D 1 Reply Last reply
          0
          • B BechBej

            Did you mean something like this? [code]

            [/code] Try to copy and paste this in a blanc scene, it that what you want then you can also do this in code behind [code]Rectangle rect = new Rectangle { Width = 50, Height = 50, Fill = new SolidColorBrush(Colors.Blue) }; Canvas.SetLeft(rect, 50); Canvas.SetTop(rect,50); [/code]

            D Offline
            D Offline
            dashingsidds
            wrote on last edited by
            #5

            Yeah something on the similar lines. I got the solution as.

                            uc1.SetValue(Canvas.TopProperty, Convert.ToDouble(12));
                            uc1.SetValue(Canvas.LeftProperty, Convert.ToDouble(12));
            

            The above will move the usercontrol uc1 12 from the top and 12 from the left. Thanks. :) Regards, Samar

            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