2
votes

I have various user controls that get placed in a content control within my Silverlight App. At present I am hard coding the width and height of the controls to fill as they don't stretch. I have set the HorizontalAlignment and VerticalAlignment to strecth (on the usercontrol and DataTemplate), but they still don't fill the space available when placed in the content control. Does anyone know what I have to do? Also, could anyone suggest a good website article on the topic of sizing controls within WPF / Silverlight?

1

1 Answers

5
votes

HorizontalContentAlignment and VerticalContentAlignment should do the trick.

<ContentControl HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Height="200" Width="200">
    <Button Content="Button" />
</ContentControl>

With this XAML, the button will take up all the available space in the ContentControl.