views:

738

answers:

1

I am needing to make a custom window with WindowStyle.None, AllowsTransparency = true, etc.

One requirement is a custom ResizeGrip control.

I have this working with ResizeMode.CanResizeWithGrip, taking some code from an open source project found here: Fluid Kit

See the "GlassWindow" class if you're interested.

To do the work, I'm calling the following code on the MouseLeftButtonDown event of the ResizeGrip:

NativeMethods.SendMessage(_interopHelper.Handle, WM.SYSCOMMAND, (IntPtr)((int)SC.SIZE + (int)sizingAction), IntPtr.Zero);

SizingAction is defined as:

    enum SizingAction
    {
        West = 1,
        East = 2,
        North = 3,
        NorthWest = 4,
        NorthEast = 5,
        South = 6,
        SouthWest = 7,
        SouthEast = 8,
    }

It is all working, but I notice some strangeness when you resize via a SouthWest (or any left or top) side. You are able to see the WPF window redraw for both a size and position change (which always occurs when resizing from the top or left).

If you try this on any window with the default window style and resize mode, it works just fine. With the exception of XP, you have to have the classic theme on.

Does anyone know an alternative to using this? Or a way to fix it?

I also posted some information on MSDN forums, here: MSDN Forums

PS - You can see this behavior first hand if someone wants to svn checkout Fluid Kit and run the GlassWindow example by setting StartupUri="GlassWindow/Window1.xaml" in their example project.

EDIT: Microsoft told me to send a product suggestion...

The link is here if anyone has a similar problem:

Product Suggestions

I also put an example here if you would like to try it first hand:

Sample

+2  A: 

Microsoft reports this happens to all WPF-windows.

Standard styles work because windows will render the title bar, window border, etc. When resizing a standard-bordered window, you can see the WPF client area flicker on any machine.

If you set WindowStyle to None, then WPF is rendering the entire window and so this flickering becomes more noticeable since the entire window flickers.

For now, the workaround is to make your window a fixed size and resize the client area. However, this is pretty performance intensive--so you might be better off to live with flickering.

You can follow my link above to my product suggestion to see if Microsoft is ever going to fix this. Please vote for it if you have a similar issue.

Jonathan.Peppers