
Hello, I was wondering if I could prevent the user from dragging the alert off screen limits, I did find IsRestricted property here https://docs.telerik.com/devtools/wpf/controls/radwindow/how-to/prevent-dragging-off-the-screen
But I could not manage to apply it to one of your predefined dialogs (Alert, Prompt, Confirm). Is there any way to do it? Couldn't there be a simple property in the DialogParameters?
Thanks in advance,
Luís Henrique
6 Answers, 1 is accepted
The DialogParameters class exposes a WindowStyle property where you can define a style targeting the created dialog (of type RadWindow) and set its IsRestricted property. Here's an example:
var style =
new
Style(
typeof
(RadWindow));
style.Setters.Add(
new
Setter(RadWindow.IsRestrictedProperty,
true
));
style.Setters.Add(
new
Setter(RadWindow.IsTopmostProperty,
true
));
RadWindow.Prompt(
new
DialogParameters()
{
Owner =
this
,
DialogStartupLocation = WindowStartupLocation.CenterOwner,
WindowStyle = style,
});
Please let me know if this works for you.
Regards,
Dilyan Traykov
Progress Telerik

Hello Dilyan, thanks for the response.
Unfortunately it did not work.
If I set a WindowStyle the dialog doesn't even show.
If I just set this:
var style =
new
System.Windows.Style(
typeof
(RadWindow));
//style.Setters.Add(new System.Windows.Setter(RadWindow.IsRestrictedProperty, true));
//style.Setters.Add(new System.Windows.Setter(RadWindow.IsTopmostProperty, true));
this
.WindowStyle = style; //Commenting this line makes everything show and work once again.
The dialogs wont show anymore. Just so you know; I'm using Windows 8 Touch theme NoXaml as defined here in my app.xaml:
<
ResourceDictionary.MergedDictionaries
>
<!--Themes-->
<
ResourceDictionary
Source
=
"/Telerik.Windows.Themes.Windows8Touch;component/Themes/System.Windows.xaml"
/>
<
ResourceDictionary
Source
=
"/Telerik.Windows.Themes.Windows8Touch;component/Themes/Telerik.Windows.Controls.xaml"
/>
<
ResourceDictionary
Source
=
"/Telerik.Windows.Themes.Windows8Touch;component/Themes/Telerik.Windows.Controls.Chart.xaml"
/>
<
ResourceDictionary
Source
=
"/Telerik.Windows.Themes.Windows8Touch;component/Themes/Telerik.Windows.Controls.Docking.xaml"
/>
<
ResourceDictionary
Source
=
"/Telerik.Windows.Themes.Windows8Touch;component/Themes/Telerik.Windows.Controls.FileDialogs.xaml"
/>
<
ResourceDictionary
Source
=
"/Telerik.Windows.Themes.Windows8Touch;component/Themes/Telerik.Windows.Controls.FixedDocumentViewers.xaml"
/>
<
ResourceDictionary
Source
=
"/Telerik.Windows.Themes.Windows8Touch;component/Themes/Telerik.Windows.Controls.FixedDocumentViewersUI.xaml"
/>
<
ResourceDictionary
Source
=
"/Telerik.Windows.Themes.Windows8Touch;component/Themes/Telerik.Windows.Controls.GridView.xaml"
/>
<
ResourceDictionary
Source
=
"/Telerik.Windows.Themes.Windows8Touch;component/Themes/Telerik.Windows.Controls.Input.xaml"
/>
<
ResourceDictionary
Source
=
"/Telerik.Windows.Themes.Windows8Touch;component/Themes/Telerik.Windows.Controls.Navigation.xaml"
/>
<
ResourceDictionary
Source
=
"/Telerik.Windows.Themes.Windows8Touch;component/Themes/Telerik.Windows.Controls.Spreadsheet.xaml"
/>
When using the implicit styles approach for styling the controls with the NoXaml binaries, you should base any styles on the default style that the theme provides. In this case, you should base the style that targets the RadWindow to the default RadWindowStyle, like so:
var baseStyle = App.Current.Resources[
"RadWindowStyle"
]
as
Style;
var style =
new
Style(
typeof
(RadWindow), baseStyle);
Please let me know if this displays the window as expected.
Regards,
Dilyan Traykov
Progress Telerik

Hello Dilyan.
It still doesn't work, the dialog simply doesn't show and the UI gets stucked/frozen.

Hello Dilyan.
It still doesn't work, the dialog simply doesn't show and the UI gets stucked/frozen.
[/quote]
Let me correct this.
It is displaying the dialog now (with the basedOn style), but the restricted limit is not working.
This is my HDialogParameters code.
/// <summary> Default constructor. It will automatically set Owner to 'App.Current.MainWindow'. </summary>
public
class
HDialogParameters : DialogParameters
{
public
HDialogParameters()
{
// Set App's MainWindow as default Owner.
this
.Owner = App.Current.MainWindow;
//// Apply a style for restricting offset limits and setting topmost.
var baseStyle = App.Current.Resources[
"RadWindowStyle"
]
as
System.Windows.Style;
var style =
new
System.Windows.Style(
typeof
(RadWindow), baseStyle);
style.Setters.Add(
new
System.Windows.Setter(RadWindow.IsRestrictedProperty,
true
));
style.Setters.Add(
new
System.Windows.Setter(RadWindow.IsTopmostProperty,
true
));
this
.WindowStyle = style;
}
}
/// <summary> Constructor. It will invoke Default Constructor and set its Owner as well. </summary>
///
/// <param name="header"> A string to be displayed in the header content. </param>
/// <param name="message"> A string to be displayed in the body content. </param>
public
HDialogParameters(
string
header,
string
message) :
this
()
{
this
.Header = header;
this
.Content =
new
TextBlock() { Text = message, TextWrapping = DefaultTextWrap, MaxWidth = DefaultMaxWidth };
}
I tested the behavior of the control with a setup similar to the one you are using. On my end everything seems to behave as expected. Can you please take a look at the attached sample application? Am I missing something?
Regards,
Stefan
Progress Telerik