This is a migrated thread and some comments may be shown as answers.

IsRestricted for Predefined Dialogs

6 Answers 258 Views
Window
This is a migrated thread and some comments may be shown as answers.
Luís Henrique
Top achievements
Rank 2
Luís Henrique asked on 31 Jan 2018, 01:45 PM

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

Sort by
0
Dilyan Traykov
Telerik team
answered on 05 Feb 2018, 10:20 AM
Hello Luís,

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
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Luís Henrique
Top achievements
Rank 2
answered on 06 Feb 2018, 08:49 PM

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" />
0
Dilyan Traykov
Telerik team
answered on 07 Feb 2018, 04:47 PM
Hello Luís,

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
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Luís Henrique
Top achievements
Rank 2
answered on 09 Feb 2018, 11:20 AM

Hello Dilyan.

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

0
Luís Henrique
Top achievements
Rank 2
answered on 09 Feb 2018, 11:26 AM
[quote]Luís Henrique said:

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 };
        }
0
Stefan
Telerik team
answered on 14 Feb 2018, 09:53 AM
Hello Luis,

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
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
Window
Asked by
Luís Henrique
Top achievements
Rank 2
Answers by
Dilyan Traykov
Telerik team
Luís Henrique
Top achievements
Rank 2
Stefan
Telerik team
Share this question
or