[英]Wpf Width binding to property with star
您是否可以将属性的宽度绑定到对象乘以星号的值,例如,
(Width =“ {Binding SizeInt *}”)以xaml表示?
在后面的代码中,您可以执行以下操作:
rect.Width = new GridLength(item.SizeInt, GridUnitType.Star);
我希望能够在xaml中具有相同的效果...
<Rectangle x:Name="rect" Fill="Red" Width="{Binding SizeInt*}"/>
有没有办法使用xaml做到这一点?
尝试绑定到GridLength
souce属性:
public GridLength SizeInt => new GridLength(1, GridUnitType.Star);
您可以将1
替换为所需的任何值,包括另一个字段的值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.