tags:

views:

76

answers:

1

Hi,

I have an app with a custom window (transparency and no borders). I made a header with a dragmove behavior on left mouse button down. This allows me to drag the window to the top so it maximizes. Now I want to write the code so that when I click the header and drag it, it restores the windowstate to normal...

Is there a click & drag event handler, or another way?

EDIT: Platform C#, in WPF

+1  A: 

You need to use Window.StateChanged Event

The best way to handle Maximalization and Minimalization is to manipulate WindowState Property. It saves the Window.RestoreBounds property with previous size. If you need more sophisticated solution

here is an example

Ps. Similar to Win 7 feature. Maybe there is no need to do so? :)

Edit: in UIElement there is MoveMove event

    private void Window_MouseMove(object sender, MouseEventArgs e)
    {
        if (e.LeftButton == MouseButtonState.Pressed)
        {
            MainWindow1.WindowState = WindowState.Normal; 
        }
    }

this is a bit messy since event is going to fire everytime you move it

lukas
Sorry but that is not what I'm looking for.... I need a handler which does something when I click and drag a ui element....
internetmw
DragDrop.GiveFeedback Attached Eventtry to be more specific i'm not quiet sure what do you want to do
lukas
I want to restore a maximized window by clicking and dragging a ui element. If user only clicks, nothing should happen, if mousebutton stays down and drags then WindowState == WindowState.Normal;
internetmw
Too bad, it doesn't do anything...
internetmw