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 5th November 2009

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

    public partial class MyWindow : Window
    {
        public MyWindow()
        {
            InitializeComponent();
            fillHeight();
        }
        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.

Posted in wpf | No Comments »

Download Snapping / Sticky / Magnetic Windows for WPF

Posted by Ricibald on 19th October 2009

Starting from Sticky Windows on CodeProject (makes your windows snapping like winamp or google talk) I adapted the project developed for standard WinForm in Wpf Application. It works with multiple monitor and with windows vista/7.

DOWNLOAD LINK.

I adapted the following interface to get the app work with WPF App:

    public interface IFormAdapter
    {
        IntPtr Handle { get; }
        Rectangle Bounds { get; set; }
        Size MaximumSize { get; set; }
        Size MinimumSize { get; set; }
        bool Capture { get; set; }
        void Activate();
        Point PointToScreen(Point point);
    }

    public class WinFormAdapter : IFormAdapter 
    {
        // Original Code Implementation
    }

    public class WpfFormAdapter : IFormAdapter 
    {
        // My Implementation
    }

Enjoy and please give me feedback!

DOWNLOAD LINK.

Posted in .net, download | 62 Comments »