I'm not sure how to go about this, but I created a custom Panel FooPanel
. I want my FooPanel to force all the children to fit within a size that is predetermined by the panel (that way they are uniform). I know about UniformGrid
but I also have some other stuff going into it.
I'm not sure how to force the children to fit within the box I tell them to.
Child.xaml:
<Style TargetType="{x:Type l:FooChild}">
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="Padding" Value="12,2,12,2" />
<Setter Property="Foreground" Value="Black" />
<Setter Property="Background" Value="White" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Stretch" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type l:FooChild}">
<Border x:Name="ChromeBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="true">
<ContentPresenter ContentSource="Header" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
HorizontalAlignment="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"
VerticalAlignment="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"
/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>