You can use the converter to calculate the height depending on the height of the window, something like this ...
You need to pass Window.ActualHeight to the converter - it will return the window height multiplied by 0.75. If, for some reason, when the converter hit, Window.ActualHeight is NULL (or you accidentally passed something that cannot be converted to double), it will return double.NaN, which will set the height to Auto.
public class ControlHeightConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { double height = value as double; if(value != null) { return value * 0.75; } else { return double.NaN; } } }
Bind this to your management so ... (obviously this is a very shortened version of haml!)
<Window x:Name="MyWindow" xmlns:converters="clr-namespace:NamespaceWhereConvertersAreHeld"> <Window.Resources> <ResourceDictionary> <converters:ControlHeightConverter x:Key="ControlHeightConverter"/> </ResourceDictionary> </Window.Resources> <ListView MaxHeight="{Binding ElementName=MyWindow, Path=ActualHeight, Converter={StaticResource ControlHeightConverter}}"/> </Window>
Tabbycool
source share