<StackPanel Name="mypanel">
<ScrollViewer Height="{Binding ElementName=mypanel, Path=ActualHeight}">
I need, that Height = mypanel.ActualHeight-60. How to do it?
<StackPanel Name="mypanel">
<ScrollViewer Height="{Binding ElementName=mypanel, Path=ActualHeight}">
I need, that Height = mypanel.ActualHeight-60. How to do it?
You need to write an IValueConverter that takes in the ActualHeight and returns a new value of that minus 60.
Something like:
[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;
}
}
<StackPanel Name="mypanel">
<ContentControl Content="{Binding HeaderPart}" /> <= here must be Expander
<ScrollViewer Height="{Binding ElementName=mypanel, Path=ActualHeight, Converter={StaticResource HeightConverter}}" >
<StackPanel>
</StackPanel>
</ScrollViewer>
When There is no Expander, all are working. When Expander is, mypanel.ActualHeight in HeightAdjustmentConverter = 0
What happend?