views:

21

answers:

2

I'm writing a form in XAML that has multiple buttons with content of different sizes (ie "OK" and "Save As...") Ideally, I'd like them all to be the smallest size possible to hold the largest content. In the example above, both buttons would be the width necessary to hold "Save As..." plus the margins and padding.

If they were Grid cells, I could use a SizeGroup. Is there a similar declaration for Buttons?

+1  A: 

If there is, I've not heard of it. Unless someone else knows better, one approach would be to create a container object that automatically sized it's contents for you. It's probably not worth the overhead. Alternately, you could edit the layout in Blend which is designed to make that sort of thing easy.

Scott J
+2  A: 

If the button labels are known ahead of time, then you could create a style that the buttons could all use, and just set the width property on that.

Otherwise, I think a custom container wouldn't be difficult at all to do for this job. Just subclass whatever container you are using, and manipulate the widths of its child elements. That doesn't sound hard at all.

Jeffrey L Whitledge