开发者

Click and drag event handler

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, 开发者_JS百科or another way?

EDIT: Platform C#, in WPF


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜