如何在模板中绑定BorderThickness? [英] How bind BorderThickness in template?

查看:234
本文介绍了如何在模板中绑定BorderThickness?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作一个简单的控件,并在其中添加一些路径.并将Path的Fill,Stroke和StrokeThickness属性绑定到模板的Background,BorderBrush和BorderThickness.Left.

I'm trying make a simple control, with a some path in it. And binding Path's Fill, Stroke and StrokeThickness properties to template's Background, BorderBrush and BorderThickness.Left.

<Path x:Name="CorePart"
   Fill="{TemplateBinding Background}"
   Stroke="{TemplateBinding BorderBrush}"
   StrokeThickness="{TemplateBinding BorderThickness.Left} 
..."

但是有一个问题:StrokeThickness不想绑定. Silverlight报告:名称空间Borderaickness在名称空间 http://schemas.microsoft.com/client /2007 "

But one problem: StrokeThickness do not want to binding. Silverlight report: "The name BorderThickness does not exist in the namespace http://schemas.microsoft.com/client/2007"

如何解决这个问题?

推荐答案

您的控件是否具有BorderThickness依赖项属性? 我认为您无法绑定到某个属性的一个属性. 我将LeftBorderThickness依赖属性添加到您的控件中,并且您可以绑定到该属性.

Does your control have a BorderThickness dependency property? I don't think you can bind to a property of a property. I'd add a LeftBorderThickness dependnecy property to your control and the you could bind to that.

这篇关于如何在模板中绑定BorderThickness?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆