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

Tri-State RadConfirm

11 Answers 383 Views
Window
This is a migrated thread and some comments may be shown as answers.
Seb Doe
Top achievements
Rank 1
Seb Doe asked on 27 May 2010, 09:20 AM
Hello,
I would like to know if there is a simple way to have a RadConfirm window with three buttons like Yes, No and Cancel.

Thank you for advance.

11 Answers, 1 is accepted

Sort by
0
Miroslav Nedyalkov
Telerik team
answered on 01 Jun 2010, 12:43 PM
Hi Seb,

 The RadConfirm doesn't support this feature. You could inherit from the RadWindow control in XAML (like you do with the UserControl class) and make it act like a three state confirm dialog and add it a static method Confirm with the appropriate parameters and use it.

Hope this helps.

Greetings,
Miroslav Nedyalkov
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
Seb Doe
Top achievements
Rank 1
answered on 01 Jun 2010, 01:47 PM
Thanks for the reply. This is the solution I would like to avoid.
I purpose to you this approach:
When the window is opened, I inject the third button with the specified content. If the user clicks on the button, it is closing the window with a dialog result as Null.

            var parameters = new DialogParameters(); 
            parameters.Opened += (sender, args) =>  
            { 
                var dialog = (RadWindow)sender; 
                var panel = (Panel)((ContentControl)dialog.Content).Template.FindName("DialogButtons", (ContentControl)dialog.Content); 
                if (panel == null || panel.Children.Count < 1
                    return; 
                var first = panel.Children[0] as RadButton; 
                if (first == null) 
                    return; 
 
                var newButton = first.CloneShallow(); 
                newButton.Content = thirdButtonContent
 
                newButton.Click += (sender2, args2) => 
                { 
                    dialog.Close(); 
                }; 
 
                panel.Children.Add(newButton); 
            }; 

I hope it could help others.
0
Miroslav Nedyalkov
Telerik team
answered on 03 Jun 2010, 02:03 PM
Hi Seb,

 Thank you for sharing your solution! I suggested you the other approach, because the preferred way of adding visual elements (like buttons) is using XAML and not using C# code for it. Anyway the suggested approach looks fine.

Regards,
Miroslav Nedyalkov
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
Alfredo
Top achievements
Rank 1
answered on 29 Aug 2011, 04:26 PM
I am sorry but this event not fire on Version 2011 2 0712 in previous version it was ok
0
Miroslav Nedyalkov
Telerik team
answered on 30 Aug 2011, 09:48 AM
Hi Alfredo,

 The Opened event is not supported anymore. We apologize for the inconvenience caused. My suggestion is to use the Style property of the Dialog parameters to change the look of the dialog and add another button. For more information on how to do this you could refer to this help article. To add a Close button just a RadButton with its Command property set to telerik:WindowCommands.Close.

Hope this helps.

Kind regards,
Miroslav Nedyalkov
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Alfredo
Top achievements
Rank 1
answered on 31 Aug 2011, 10:29 PM
I used this code to Set Focus in cancel button.

RadWindow.Confirm(
                    new DialogParameters()
                    {
                        Closed = (s, closedEvent) =>
                        {
                            // something here
                        },
                        Opened = (s, openedEvent) =>
                        {
                            RadWindow confirm = s as RadWindow;
                            Button Cancel = confirm.ChildrenOfType<Button>()[5];
                            FocusManager.SetIsFocusScope(confirm, true);
                            FocusManager.SetFocusedElement(confirm, Cancel);
                        },
                        Content = "Delete ?",
                        Header = "Confirm",
                        Owner = this
                    });

What should i do if i can not use this event ?
0
Konstantina
Telerik team
answered on 01 Sep 2011, 02:04 PM
Hi Alfredo,

You could create an attached property which when set is hooking to the Loaded event of the Window. When the Loaded event fires it focuses the button. After that you should change the template and set it to the button.

Hope this information helps.

Kind regards,

Konstantina
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Michael
Top achievements
Rank 1
answered on 04 Feb 2019, 03:40 PM

Personally, I think this is absolutely a horrible solution to this problem.

 

Anyway, for me I need to add a third button to a RadWindow.Confirm dialog. I have a custom template in a style already, I can easily add the third button. What I'm not sure about is how I can add a clicked event handler to that third dialog button. Any suggestions? Thanks.

0
Dinko | Tech Support Engineer
Telerik team
answered on 07 Feb 2019, 10:35 AM
Hi Michael,

An approach which I could suggest you is to bind the Command property of the RadButton to a command from your ViewModel. I have prepared a sample project which demonstrates this behavior. Give this approach a try and let me know if it works for you.

Regards,
Dinko
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Michael
Top achievements
Rank 1
answered on 21 Feb 2019, 07:01 PM

Thanks Dinko,

 

Now, how can you close the dialog from within the command that is being executed from the custom button?

 

0
Dinko | Tech Support Engineer
Telerik team
answered on 25 Feb 2019, 12:45 PM
Hello Michael,

You can pass the RadWindow element which wraps the dialog to the CommandParameter. Then in the executed method of the command, you can get the RadWindow and call its Close() method. The following code snippet demonstrates how to pass the RadWindow using RelativeSource to the CommandParameter.

<Style x:Key="RadConfirmStyle" TargetType="telerik:RadConfirm">
    <Setter Property="IsTabStop" Value="False"/>
    <Setter Property="MinWidth" Value="275"/>
    <Setter Property="MaxWidth" Value="500"/>
    <Setter Property="SnapsToDevicePixels" Value="True"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="telerik:RadConfirm">
                <!--Your custom template-->
                <telerik:RadButton Content=" My Button" Command="{Binding Content.MyCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=telerik:RadConfirm}}" CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=telerik:RadWindow,Mode=FindAncestor}}"/>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

Now you can just cast the parameter as RadWindow.
public class MainViewModel
{
    public ICommand MyCommand { get; set; }
    public MainViewModel()
    {
        MyCommand = new DelegateCommand(OnCommandExecuted);
    }
 
    private void OnCommandExecuted(object obj)
    {
        var window = obj as RadWindow;
        window.Close();
    }
}

Hope this approach will work on your side.

Regards,
Dinko
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Window
Asked by
Seb Doe
Top achievements
Rank 1
Answers by
Miroslav Nedyalkov
Telerik team
Seb Doe
Top achievements
Rank 1
Alfredo
Top achievements
Rank 1
Konstantina
Telerik team
Michael
Top achievements
Rank 1
Dinko | Tech Support Engineer
Telerik team
Share this question
or