В настоящее время я использую WPF .NET 3.5 для разработки, используя математический конвертер ikriv, я решил выполнить математическую задачу в своем проекте:
<ControlTemplate x:Key="RectangleTemplate">
<Grid Background="Transparent">
<Rectangle x:Name="Shape" Stroke="#d69e31" Fill="{StaticResource YellowGradientBrush}">
<!-- Create a rectangle that applies Cornering accoding to it's (in form) indicated height -->
<Rectangle.RadiusX>
<MultiBinding Converter="{StaticResource MathConverter}" ConverterParameter="x/2.5">
<!-- Error occurs in the line below -->
<Binding Path="Object" ElementName="{TemplateBinding Property=Button.Height}" />
</MultiBinding>
</Rectangle.RadiusX>
<Rectangle.RadiusY>
<MultiBinding Converter="{StaticResource MathConverter}" ConverterParameter="x/2.5">
<!-- Error occurs in the line below -->
<TemplateBinding Property="Button.Height" />
</MultiBinding>
</Rectangle.RadiusY>
</Rectangle>
</Grid>
</ControlTemplate>
+ Помощник по исключениям говорит:
InnerException: System.InvalidCastException
Сообщение = Невозможно привести объект типа 'System.Windows.TemplateBindingExpression' к типу 'System.String'.
Спасибо.