开发者

WPF - Binding plus a tweak

I am wondering if there is a way with WPF binding to se开发者_开发问答t the value via binding plus tweak it.

For example I have the width of a border being set to the canvas that contains it:

Width="{Binding Width, ElementName=mainCanvas, Mode=Default}"

Because I am doing a border with rounded corners. the Canvas.Top and Canvas.Left for the border are both set to -5. This makes the border end 5 too soon (really 10 too soon with the rounded corners on the other side).

Is there a way to do something similar to this:

Width="{Binding Width, ElementName=mainCanvas, Mode=Default} + 5"


Either write your own IValueConverter that does that, and specify it in the binding, or use some of the existing generic ones that allow you to embed expressions directly into XAML - e.g. PyBinding.


Creating a ValueConverter would work. See this video tutorial: http://windowsclient.net/learn/video.aspx?v=26730

You may also look into using the Margin property.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜