문제

현재 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>
.

+ 예외 assist는 다음과 같습니다 :

InnerException : System.InvalidCastException

message= '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