首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >xaml中的绑定,xaml解析异常

xaml中的绑定,xaml解析异常
EN

Stack Overflow用户
提问于 2012-03-01 02:03:07
回答 1查看 1.3K关注 0票数 1

我目前正在使用.NET 3.5进行开发,使用ikriv的数学转换器,我决定在我的设计中做一个数学任务:

代码语言:javascript
复制
<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>

+Exception assist表示:

InnerException: System.InvalidCastException

将'System.Windows.TemplateBindingExpression‘类型的对象强制转换为'System.String’类型的Message=Unable。

谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-03-01 02:39:20

是的,该行中有一个错误。请提供更多信息,说明您在绑定中引用的按钮在哪里。

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

代码语言:javascript
复制
<!-- this line causes an error -->
<Binding Path="Object" ElementName="{TemplateBinding Property=Button.Height}" />

并将其替换为新的:

代码语言:javascript
复制
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Height" />
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9504301

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档