我目前正在使用 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>
+异常协助 说:
内部异常:System.InvalidCastException
消息=无法将“System.Windows.TemplateBindingExpression”类型的对象转换为“System.String”类型。
谢谢。