I have a custom Silverlight control that extends Panel. I require the data template (root node is stack panel) to take 100% of the available width - at present, however, the stack panel only fills to the width of the text.
The arrange override in my control:
protected override Size MeasureOverride(Size availableSize)
{
foreach (FrameworkElement element in Children)
{
element.Measure(new Size(availableSize.Width, availableSize.Height));
}
return base.MeasureOverride(availableSize);
}
And my template:
<DataTemplate x:Name="itemTemplate">
<StackPanel Background="Aqua" HorizontalAlignment="Stretch">
<TextBlock TextWrapping="Wrap" Text="{Binding Name}" HorizontalAlignment="Stretch"/>
</StackPanel>
</DataTemplate>
Any help would be greatly appreciated.