View Single Post
Old 10-22-2008   #1 (permalink)
WernerG


 
 

How do I retrieve control runtime size values in C#?

Hello.

I am currently designing a WPF UI programmatically in C#. One of the custom
controls I am designing is a horizontal menu containing a set amount of
visually displayed buttons. The menu can contain more buttons that is
actually displayed and to get to them I have scroll buttons at the side.

Now, my Control that contains the buttons is a stackpanel with a horizontal
orientation. This stackpanel will be inserted into a grid that is chopped up
using GridUnitType.Star values.

My problem is that I cannot determine at run time what the size of my
stackpanel is. I do not programmatically set its size since it is set to fill
up the entire grid horisontally. ( Stretch ). I need the stackpanel's width
so that I can determine the correct size of my N buttons that I want to
insert into it. For example; my stackpanel's length is 80 and I want it to be
able to display 5 buttons so that give a button width of 80/5. I cannot get
that 80 at runtime.

Any help will be appreciated.

Regards,

Werner

My System SpecsSystem Spec