Thursday, June 12, 2008

[Silverlight B2, C#] Custom User Controls "Overlap" in StackPanel...???

Ok, so I'm going to put money on the fact that I am doing something wrong... but I have no clue what. Here's the run down:
  • I created a User Control for a ProgressBar
    • XAML consists of a Canvas, border Rectangle, fill Rectangle, and a TextBlock.
    • C# code simply allows for the "percentComplete" which will change the width of the fill bar and the text accordingly. It's really rather simple.
  • I created a User Control for a ProgressArea
    • XAML consists of a StackPanel that will contain one or more ProgressBars.
    • C# code has an "AddBar" function which will create a new ProgressBar and then add it into the StackPanel.
Seems simple... however, when I add more then one ProgressBar they "overlap" each other. It's like the StackPanel has no idea about the width/height of each control. I know that they are overlapping because if I set the margin to something like "20,20,0,0" I can SEE both of them.

When I add multiple standard controls to the StackPanel [like TextBlock] they stack fine. Obviously I am not setting something correctly in my custom control... just have no idea what. Once again my google search has turned up nothing.

So if anyone is ACTUALLY reading this, and knows what's up... PLEASE let me know!!! I will like love you forEVAR :)


EDIT: Ok so... I'm not certain exactly what happened. I was playing around with getting around this problem by setting the margin of each ProgressBar to be just a smidge bigger then the height of the bar. And after setting it and then removing it... the stack panel seems to work fine now. My controls are stacking on top of each other just fine WITHOUT my margin setting.

/Shrug. No idea. But I'm not going to complain.


.

No comments: