Issue with setting the margin on several WPF controls
-
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? -
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?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 PageJust a grain of sand on the worlds beaches.
-
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 PageJust a grain of sand on the worlds beaches.
TasksIcos.Margin.Left = -192 at runtime and in blend.
-
TasksIcos.Margin.Left = -192 at runtime and in blend.
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 PageJust a grain of sand on the worlds beaches.
-
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 PageJust a grain of sand on the worlds beaches.
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.
-
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.
Glad you got it all working!
Cheers, Karl
» CodeProject 2008 MVP My Blog | Mole's Home Page | XAML Power Toys Home PageJust a grain of sand on the worlds beaches.