Did you try to install
Application.Current.MainWindow.Height = 100;
Short addition: I just did a short test, in code:
public partial class MainWindow : Window, INotifyPropertyChanged { private int _height; public int CustomHeight { get { return _height; } set { if (value != _height) { _height = value; if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("CustomHeight")); } } } public MainWindow() { InitializeComponent(); this.DataContext = this; CustomHeight = 500; } public event PropertyChangedEventHandler PropertyChanged; private void Button_Click(object sender, RoutedEventArgs e) { CustomHeight = 100; } }
and xaml:
<Window x:Class="WindowSizeTest.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="{Binding CustomHeight, Mode=TwoWay}" Width="525"> <Grid> <Button Click="Button_Click">Test</Button> </Grid>
Press the button to set the height of the window. Is this what you are looking for?
source share