protected void EnableDragable(Grid container, AppTitleBar control) { _control = control; _container = container; _control.PreviewMouseUp += (s, e) => e.MouseDevice.Capture(null); _control.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(control_MouseLeftButtonUp); _control.PreviewMouseMove += new MouseEventHandler(control_MouseMove); }
public override void OnApplyTemplate() { base.OnApplyTemplate(); Grid mainGrd = GetTemplateChild("mainGrd") as Grid; AppTitleBar titlebar = GetTemplateChild("titlebar") as AppTitleBar; titlebar.appClose.MouseLeftButtonUp += (s, e) => WindowAction(AppWindowState.CloseRequest); titlebar.appMaximize.MouseLeftButtonUp += (s, e) => WindowAction(AppWindowState.Maximize); titlebar.appMinimize.MouseLeftButtonUp += (s, e) => WindowAction(AppWindowState.Minimize); EnableDragable(mainGrd, titlebar); }