private void DialogFrameParentClick(object s, MouseButtonEventArgs e) { if (CurrentDialog != null && CurrentDialog.AllowClickMaskToClose) { Point point = e.GetPosition(DialogFrame); double X = point.X; double Y = point.Y; Point contentPont = ContentPanel.TranslatePoint(new Point(0, 0), DialogFrame); if ((X < 0 && X > contentPont.X) || (Y < 0 && Y > contentPont.Y) || X > DialogFrame.ActualWidth || Y > DialogFrame.ActualHeight) { CurrentDialog.OnCancelInvoke(); Close(); } } }