パスを含むコントロールテンプレートがあります(他のコントロール以外)。コントロールのサイズを変更するときに、パスのサイズを変更する必要があります。パスを表すポイントとサイズは、コントロールサイズの相対的な割合として表すことができます。
テンプレートの抜粋は次のとおりです。
<Path Stroke="Gray" StrokeThickness="5">
<Path.Data>
<PathGeometry>
<PathFigure StartPoint="{TemplateBinding Start}" >
<ArcSegment Point="{TemplateBinding End}" Size="{TemplateBinding Size}" RotationAngle="0" IsLargeArc="True" />
</PathFigure>
</PathGeometry>
</Path.Data>
</Path>
StartとEndはPoint型のDependencyPropertiesであり、SizeはSize型のDependencyPropertyです。
私が現在行っているのは、FrameworkElement.SizeChangedイベントをリッスンしています。
void OperationModeIndicator_SizeChanged( object sender, SizeChangedEventArgs e )
{
this.Size = new Size( e.NewSize.Width * 0.45f, e.NewSize.Height * 0.45f );
this.Start = new Point( e.NewSize.Width * 0.35f, e.NewSize.Height * 0.1f );
this.End = new Point( e.NewSize.Width * 0.65f, e.NewSize.Height * 0.1f );
}
問題は次のとおりです。パスのプロパティを親コントロールのサイズにバインドする別の(よりエレガントな)方法はありますか?