.net xaml中的绑定,xaml解析异常

.net xaml中的绑定,xaml解析异常,.net,xaml,xamlparseexception,.net,Xaml,Xamlparseexception,我目前正在使用WPF.NET 3.5进行开发,使用ikriv的数学转换器,我决定在设计中完成一项数学任务: <ControlTemplate x:Key="RectangleTemplate"> <Grid Background="Transparent"> <Rectangle x:Name="Shape" Stroke="#d69e31" Fill="{StaticResource YellowGradientBrush}">

我目前正在使用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

Message=无法将“System.Windows.TemplateBindingExpression”类型的对象强制转换为“System.String”类型


谢谢。

是的,那行有错误。请提供更多关于您在该绑定中引用的按钮的位置的信息

如果是为其创建模板的控件,则可以尝试删除该行:

<!-- this line causes an error -->
<Binding Path="Object" ElementName="{TemplateBinding Property=Button.Height}" />

并将其替换为新的:

<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Height" />

是,该行有错误。请提供一些有关您希望此绑定执行的操作的信息。