Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <Popup x:Name="pop" IsOpen="True" Height="200" Placement="AbsolutePoint" Width="200">
- <Rectangle Stretch="Fill" Fill="Red"/>
- </Popup>
- pop.MouseMove += new MouseEventHandler(pop_MouseMove);
- void pop_MouseMove(object sender, MouseEventArgs e)
- {
- if (e.LeftButton == MouseButtonState.Pressed)
- {
- pop.PlacementRectangle = new Rect(new Point(e.GetPosition(this).X,
- e.GetPosition(this).Y),new Point(200,200));
- }
- }
- Private Point startPoint;
- private void Window_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
- {
- startPoint = e.GetPosition(null);
- }
- private void Window_MouseMove(object sender, MouseEventArgs e)
- {
- if (e.LeftButton == MouseButtonState.Pressed)
- {
- Point relative = e.GetPosition(null);
- Point AbsolutePos = new Point(relative.X + this.Left, relative.Y + this.Top);
- this.Top = AbsolutePos.Y - startPoint.Y;
- this.Left = AbsolutePos.X - startPoint.X;
- }
- }
Add Comment
Please, Sign In to add comment