我看到了其他处理网格并建议"2*"的答案,但在这种情况下,此表达式不起作用。知道吗?
绑定到窗口。实际高度,并使用转换器(DivideByTwoConverter,或更通用的东西,如接受参数的乘法转换器)
public class DoubleMultiplyConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (!(value is double)) return null;
double multiplier = 1;
double.TryParse(parameter as string, out multiplier);
return ((double)value) * multiplier;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
// Not needed
return null;
}
}
XAML:
<Window x:Name="window">
<Popup Height="{Binding ActualHeight, ElementName=window, Converter=...}" />
</Window>