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. Issue with setting the margin on several WPF controls

Issue with setting the margin on several WPF controls

Scheduled Pinned Locked Moved WPF
csharpwpfhelpquestion
6 Posts 2 Posters 1 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.
  • R Offline
    R Offline
    robertw019
    wrote on last edited by
    #1

    Ok, So I'm trying to programatically set the left margin on three controls, a textblock named "Clock", a StackPanel named "TasksIcos", and a button named "Options". This is the code I'm using: TasksIcos.Margin = New Thickness(TasksIcos.Margin.Left + 32, TasksIcos.Margin.Top, TasksIcos.Margin.Right, TasksIcos.Margin.Bottom) Options.Margin = New Thickness(-MiniModePanel.Width + 43, Options.Margin.Top, Options.Margin.Right, Options.Margin.Bottom) Clock.Margin = New Thickness(Clock.Margin.Left + 43, 0, -7, 0) The only one that moves any at all, is "Options". The other two do not move regardless of what the values are entered. Can a WPF guru tell me what I'm doing wrong here?

    L 1 Reply Last reply
    0
    • R robertw019

      Ok, So I'm trying to programatically set the left margin on three controls, a textblock named "Clock", a StackPanel named "TasksIcos", and a button named "Options". This is the code I'm using: TasksIcos.Margin = New Thickness(TasksIcos.Margin.Left + 32, TasksIcos.Margin.Top, TasksIcos.Margin.Right, TasksIcos.Margin.Bottom) Options.Margin = New Thickness(-MiniModePanel.Width + 43, Options.Margin.Top, Options.Margin.Right, Options.Margin.Bottom) Clock.Margin = New Thickness(Clock.Margin.Left + 43, 0, -7, 0) The only one that moves any at all, is "Options". The other two do not move regardless of what the values are entered. Can a WPF guru tell me what I'm doing wrong here?

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

      I'm spitballing, but what is the value of TaskIcos.Margin when this code runs? Is it null? If so, that is your problem. Step through your code and see what is actually getting created.

      Cheers, Karl » CodeProject 2008 MVP My Blog | Mole's Home Page | XAML Power Toys Home Page

      Just a grain of sand on the worlds beaches.

      R 1 Reply Last reply
      0
      • L Lost User

        I'm spitballing, but what is the value of TaskIcos.Margin when this code runs? Is it null? If so, that is your problem. Step through your code and see what is actually getting created.

        Cheers, Karl » CodeProject 2008 MVP My Blog | Mole's Home Page | XAML Power Toys Home Page

        Just a grain of sand on the worlds beaches.

        R Offline
        R Offline
        robertw019
        wrote on last edited by
        #3

        TasksIcos.Margin.Left = -192 at runtime and in blend.

        FeedMonster 2.0, FeedMonster 2.0 Hourly builds

        L 1 Reply Last reply
        0
        • R robertw019

          TasksIcos.Margin.Left = -192 at runtime and in blend.

          FeedMonster 2.0, FeedMonster 2.0 Hourly builds

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

          Can you post the XAML that these controls are in? This will help me get context so I can create my own test application. BTW: When does this above code run? Can you please post the entire method that these assingments run in.

          Cheers, Karl » CodeProject 2008 MVP My Blog | Mole's Home Page | XAML Power Toys Home Page

          Just a grain of sand on the worlds beaches.

          R 1 Reply Last reply
          0
          • L Lost User

            Can you post the XAML that these controls are in? This will help me get context so I can create my own test application. BTW: When does this above code run? Can you please post the entire method that these assingments run in.

            Cheers, Karl » CodeProject 2008 MVP My Blog | Mole's Home Page | XAML Power Toys Home Page

            Just a grain of sand on the worlds beaches.

            R Offline
            R Offline
            robertw019
            wrote on last edited by
            #5

            Actually, I figured out not 10 mins after my last post. It seemed to be something with the animation that plays right before any of the actual code is run. I re-did the animation after screwing it up doing something else, and everything seemed to start moving when it supposed to. Thanks for your help though, and I apologize if I wasted your time.

            FeedMonster 2.0, FeedMonster 2.0 Hourly builds

            L 1 Reply Last reply
            0
            • R robertw019

              Actually, I figured out not 10 mins after my last post. It seemed to be something with the animation that plays right before any of the actual code is run. I re-did the animation after screwing it up doing something else, and everything seemed to start moving when it supposed to. Thanks for your help though, and I apologize if I wasted your time.

              FeedMonster 2.0, FeedMonster 2.0 Hourly builds

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

              Glad you got it all working!

              Cheers, Karl » CodeProject 2008 MVP My Blog | Mole's Home Page | XAML Power Toys Home Page

              Just a grain of sand on the worlds beaches.

              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