Programming Languages Hacks

Importanti regole per linguaggi di programmazione rilevanti come Java, C, C++, C#…

  • Subscribe

  • Lettori

    I miei lettori abituali

  • Twitter

How to Maximize Wpf Window only vertically or horizontally

Posted by Ricibald on November 5th, 2009

To maximize Wpf Window only vertically or horizontally simply use this snippet code:

    public partial class MyWindow : Window
        public MyWindow()
        private void fillHeight()
            PropertyChangedCallback tmpChanged =
                (source, args) =>
                        var workArea = (Rect)args.NewValue;
                        this.Height = workArea.Height;
            DependencyProperty tmp = DependencyProperty.Register("tmp", typeof (Rect), typeof (Window), new PropertyMetadata(new PropertyChangedCallback(tmpChanged)));
            this.SetResourceReference(tmp, SystemParameters.WorkAreaKey);

In this way you can subscribe to notifications of a DynamicResource when you have to convert the value.

Leave a Reply

You must be logged in to post a comment.