I would like to allow the user to close the RadWindow in ShowDialog() mode by clicking outside of the window. I know I can set the color of this background area using the ModalBackground property... but is there a way to handle a mouse click on this?
Thanks for the help!
Thanks for the help!
4 Answers, 1 is accepted
0
Hello Kevin,
There is no easy way to achieve this. You have to find the Rectangle which illustrates the modal background and hook to its mouse click event. The modal background is created dynamically, so you will have to find the visual parent of the RadWindow.
Hope this information helps.
Regards,
Konstantina
the Telerik team
There is no easy way to achieve this. You have to find the Rectangle which illustrates the modal background and hook to its mouse click event. The modal background is created dynamically, so you will have to find the visual parent of the RadWindow.
Hope this information helps.
Regards,
Konstantina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Tom
Top achievements
Rank 1
answered on 07 Feb 2012, 03:01 PM
I was looking for a solution to this problem and found that the object you are looking for is in fact a Canvas.
0
Tom
Top achievements
Rank 1
answered on 08 Feb 2012, 03:12 PM
Upon further exploration I have come up with a solution that works well. Hopefully someone will find it useful:
RadWindow PopupWindow;
public
SampleView()
{
InitializeComponent();
PopupWindow =
new
RadWindow { Header =
"Details"
, Name =
"radWindow"
};
PopupWindow.Loaded +=
new
RoutedEventHandler(PopupWindow_Loaded);
}
void
PopupWindow_Loaded(
object
sender, RoutedEventArgs e)
{
Canvas canvas = Framework.Traversal.FirstVisualAncestorOfType<Canvas>(PopupWindow);
canvas.MouseLeftButtonDown -= canvas_MouseLeftButtonDown;
canvas.MouseLeftButtonDown += canvas_MouseLeftButtonDown;
}
void
canvas_MouseLeftButtonDown(
object
sender, MouseButtonEventArgs e)
{
Point mousepoint = e.GetPosition(
null
);
var elements = VisualTreeHelper.FindElementsInHostCoordinates(mousepoint, PopupWindow);
if
(elements.Count() == 0)
PopupWindow.Close();
}
0
Hello Tom,
Thank you for sharing your solution with the community.
Greetings,
Konstantina
the Telerik team
Thank you for sharing your solution with the community.
Greetings,
Konstantina
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>