Reputation: 1603
<Style x:Key="MyControl" TargetType="UserControl">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Grid>
<Path Style="{StaticResource PathA}"/>
<Path Margin="8" Style="{StaticResource PathB}" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
In this usercontrol
style, I put a path
behind another path
, which has a margin
of 8.
Everthing goes fine if I create a usercontrol
with height
/width
large enough.
Problem is, the PathB
would be shrunk out of sight if the size is near or below 8.
I know it's the margin
which pushed PathB
. Isn't margin
a relative value in a usercontrol
? How can I handle this if I want to keep a little space between PathA
and PathB
even when resizing?
In the second pic the orange pie is missing because it's shrunk by the margin.
Upvotes: 0
Views: 1049
Reputation: 13669
you may perhaps define a minimum width and height to the grid or path or even user control.
<Style x:Key="MyControl" TargetType="UserControl">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Grid MinWidth="12" MinHeight="12">
<Path Style="{StaticResource PathA}"/>
<Path Margin="8" Style="{StaticResource PathB}" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
or perhaps use a ViewBox here
<Style x:Key="MyControl" TargetType="UserControl">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Viewbox>
<Grid>
<Path Style="{StaticResource PathA}"/>
<Path Margin="8" Style="{StaticResource PathB}" />
</Grid>
</Viewbox>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
ViewBox will keep the proportion intact while re-sizing the content
Upvotes: 2