Pergunta

Atualmente estou usando o WPF .NET 3.5 para o desenvolvimento, utilizando o ikriv de Matemática Conversor, eu decidi fazer uma tarefa de matemática, na minha concepção:

<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>

+De exceção auxiliar diz:

InnerException:Do sistema.InvalidCastException

Mensagem=não é Possível converter objeto do tipo 'System.O Windows.TemplateBindingExpression' para o tipo 'System.Seqüência de caracteres'.

Obrigado.

Foi útil?

Solução

Sim, há um erro na linha.Por favor, dê mais algumas informações sobre onde é o botão que você referem-se a essa ligação.

Se é o controle que você criar o modelo, você pode tentar remover a linha:

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

e substituí-lo por um novo:

<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Height" />
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top