<StackPanel Name="mypanel">
<ScrollViewer Height="{Binding ElementName=mypanel, Path=ActualHeight}">我需要,Height = mypanel.ActualHeight-60。
我该怎么做呢?
编辑:
<StackPanel Name="mypanel">
<ContentControl Content="{Binding HeaderPart}" /> <= here must be Expander
<ScrollViewer Height="{Binding ElementName=mypanel, Path=ActualHeight, Converter={StaticResource HeightConverter}}" >
<StackPanel>
</StackPanel>
</ScrollViewer>当没有Expander时,一切都在工作。当Expander是,mypanel.ActualHeight,HeightAdjustmentConverter = 0。
发生了什么?
发布于 2010-08-16 11:10:04
您需要编写一个IValueConverter,它接受ActualHeight并返回一个新值- 60。
类似于:
[ValueConversion(typeof(double), typeof(double))]
public class HeightAdjustmentConverter: IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
double original = (double)value;
return double - 60;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
double adjusted = (double)value;
return adjusted + 60;
}
}https://stackoverflow.com/questions/3492532
复制相似问题