Вопрос

Я в настоящее время использую 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>
.

+ Assister Assist:

Innerexception: System.invalidcastexception

Сообщение= Невозможно изменить объект типа «System.windows.templateBindingExpression» для типа «System.String».

спасибо.

Это было полезно?

Решение

Yes, there is an error in that line. Please give some more information about where is the button you refer to in that binding.

If it's the control that you create template for, you can try to remove the line:

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

and replace it with a new one:

<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Height" />
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top