Does anyone know a good way to minimize the width of a ToggleButton to only the width of the content plus padding? I've found 500 posts on how to make it stretch, but none for keeping it from stretching to fill the available space.
+1
A:
<ToggleButton
HorizontalAlignment="Left"
VerticalAlignment="Top"
Content="hurf" />
Just tested, this is roughly the size of the content.
Will
2009-08-14 19:02:35
A:
This depends on the containing element of the ToggleButton - I believe that on a Grid, StackPanel, or DockPanel, the button will stretch to fill available space if you don't set Width + Height or MaxWidth + MaxHeight.
I just tried:
<Grid>
<ToggleButton Content="Toggle" Width="50" Height="50" />
</Grid>
And
<Grid>
<ToggleButton Content="Toggle" MaxWidth="50" MaxHeight="50" />
</Grid>
Both limited the size of the button in a Grid. Your best bet may be to estimate a maximum size for the content that will be placed in the button and set the Max properties.
Dave M
2009-08-14 19:06:33