我试图使用控制到家长的高度/宽度属性的ElementName
和路径绑定。然而,我不想绑定到的实际高度,而是正好一半的高度。
在路径
EX pression可以做数学题?
I'm trying to bind a control to the parent's Height/width property using ElementName
and a Path. However, I don't want to bind to the actual height, but to exactly half the height.
Can the Path
expression do the math?
例如。 路径= {的ActualHeight / 2}
我无法找到一个方法来做到这一点。是否有任何其他聪明的做法?
I couldn't find a way to do that. IS there any other clever approach?
谢谢!
没有它不能,你应该使用的装订器
No it can't you should use binding converters
public class MyConverter : IValueConverter
{
public object Convert(object value, Type targetType,
object parameter, CultureInfo culture)
{
return (int)value/2;
}
public object ConvertBack(object value, Type targetType,
object parameter, CultureInfo culture)
{
return null;
}
}