If you do not specify the width or height of the ellipse, the default values will be "Auto". Combined with the default Stretch HorizontalAlignment / VerticalAligment, this should cause the ellipse to “stretch” across the width and height of its container (with a constant thickness thickness).
* ContentAlignment , , unset , .
: , , ( , " " ).
MultiBinding ActualWidth ActualHeight. " ", .
, :
class MinimumValueConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return values.Cast<double>().Min();
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
:
<Window.Resources>
<l:MinimumValueConverter x:Key="MinimumValueConverter" />
</Window.Resources>
<Ellipse Stroke="Black" StrokeThickness="1">
<Ellipse.Width>
<MultiBinding Converter="{StaticResource MinimumValueConverter}">
<Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type UIElement}}" Path="ActualWidth" />
<Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type UIElement}}" Path="ActualHeight" />
</MultiBinding>
</Ellipse.Width>
<Ellipse.Height>
<MultiBinding Converter="{StaticResource MinimumValueConverter}">
<Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type UIElement}}" Path="ActualWidth" />
<Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type UIElement}}" Path="ActualHeight" />
</MultiBinding>
</Ellipse.Height>
</Ellipse>