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

RadAlert or RadConfirm with yes-no-cancel

16 Answers 1527 Views
Window
This is a migrated thread and some comments may be shown as answers.
Ivan Kopcanski
Top achievements
Rank 1
Ivan Kopcanski asked on 15 Jun 2010, 02:47 PM
Hi,
    Is there any way to show RadAlert or RadConfirm message box with 'Yes', 'No' and 'Cancel' buttons?
If this feature is somehow implemented it will be very convenient for the options scenario like this one:

1.) Yes = Save and close
2.) No = Don't save and close
3.) Cancel = Don't save and don't close

16 Answers, 1 is accepted

Sort by
0
George
Telerik team
answered on 17 Jun 2010, 01:48 PM
Hello Ivan Kopcanski,

Thank you for contacting Telerik Support.

You cannot achieve such an implementation using RadAlert or RadConfirm dialogs.
The predefined dialogs(RadAlert, RadPrompt and RadConfirm) are defines to handle a few scenarios:

  • RadAlert - Alert the user with a certain message - allows to set OkButtonContent 
  • RadPrompt - Prompt the user for a certain information - allows to set OkButtonContent and CancelButtonContent
  • RadConfirm - Allow the user to confirm an action - allows to set OkButtonContent and CancelButtonContent
You can use RadWindow instead of RadAlert or RadConfirm dialogs to achieve the scenario you want.
You can find more information about RadWindow here and about PredefinedDialogs - here.

I hope this information helps. I will be glad to assist you further.

 

Regards,
George
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
Ivan Kopcanski
Top achievements
Rank 1
answered on 26 Jul 2010, 03:31 PM
Hi
Does that mean that I must build dialog control from the scratch or RadWindow already supports showing window with yes, no and cancel buttons? I already use RadWindow.Confirm() and Prompt() for presenting message boxes with custom content, but I really need to be able to set additional cancel button beside the two existing ones. 
0
George
Telerik team
answered on 29 Jul 2010, 12:22 PM
Hello Ivan Kopcanski,

Thank you for contacting us.

You need to set a custom Style for ContentStyle of your RadConfirm window. 

Attached you can find a sample. Please, note that the names of the buttons must be different than "OK" and  "Cancel", if you want to override the logic in the handlers -  check the attachment.

I hope this helps! I will be glad to assist you further.

Sincerely yours,
George
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
Ivan Kopcanski
Top achievements
Rank 1
answered on 31 Jul 2010, 09:27 AM
Thanks :) This will cover my needs, I hope so.
0
Jan
Top achievements
Rank 1
answered on 05 Aug 2010, 11:19 AM
Hello, 
I have some problems with an example :(
The thing is, you defined a template in a xaml page, and subscribed for the click events directly in the code behind, but I cannot do that.. I need to have template in a Resources file and call a RadWindow.Confirm in a regular class, but then I do not know how to subscribe to button clicks..
I tough about a way to catch OnApplyTemplate somehow but I don't know how.
Could you help me please?
0
George
Telerik team
answered on 10 Aug 2010, 12:10 PM
Hello Robert Lukkenaer,

Thank you for contacting us.

I suggest you using Commands to subscribe to button clicks. Attached you can find the sample.

I hope this helps! Please do not hesitate to contact us if you require any further information.


Kind regards,
George
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
Denis Vuyka
Top achievements
Rank 1
answered on 27 May 2011, 11:28 AM
I think "yes/no/cancel" behavior is classics and should not require styles, commands and other customization manipulations. It is possible to have an out-of-box support for such a dialog?
0
Denis Vuyka
Top achievements
Rank 1
answered on 27 May 2011, 11:32 AM
Hello George,
According to the sample solution from this thread... how do I make the custom dialog behave like dialog? I mean closing it upon button click? For the moment the command binding is fired but is has no awareness of the dialog hosting the button. How should it be closed after command binding finished its work?
Thanks,
Denis
0
George
Telerik team
answered on 02 Jun 2011, 08:24 PM
Hi Denis,

 
You could get the original source from the ExecutedRoutedEventArgs.OriginalSource property. In this scenario, it will be the RadButton control which is hosted in the RadWindow. So, we could get the RadWindow using ParentOfType<RadWindow>() method and close the RadWindow. Please, refer to the following code snippet:

private void CommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            string source = Convert.ToString(e.Parameter);
 
            var radWindow = (e.OriginalSource as UIElement).ParentOfType<RadWindow>();
            if (radWindow != null)
            {
                radWindow.Close();
            }
        }

I hope this helps.


Regards,
George
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
Palak
Top achievements
Rank 1
answered on 15 Sep 2012, 10:03 AM
thanks

0
Jozef
Top achievements
Rank 1
answered on 26 Mar 2013, 07:32 AM
Can you please tell me why are buttons in your example disabled?
I just changed Silverlight 4 to 5 and of course I changed referencies to newest version.
0
Ye
Top achievements
Rank 1
answered on 30 Apr 2013, 08:04 AM
my solution became like this also.

all the buttons became disable.

how to solve this problem?
0
George
Telerik team
answered on 02 May 2013, 09:02 AM
Hello,

 
You can find attached the modified sample. Hope this helps.

All the best,
George
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Kashif
Top achievements
Rank 1
answered on 17 Jun 2014, 05:07 PM
Hi George,

I need to modify RadWindow.Alert for error and success message. for that i need to change it icon for different messages. i need your help in this regard. i look in IconContent propert of DialogParameters but i am not sure that it works for me or not and i don't know how to use this property.

Thanks in advance.
Kashif Amin.
0
Lance | Manager Technical Support
Telerik team
answered on 19 Jun 2014, 09:59 AM
Hi,

I have written a sample for you to see how to bind the image source and change it according to the user's selection. I've left comments in the code for you to see what I've done.

When you download the sample, rebuild the solution and run the project



Note: If you do not have Telerik installed in the default location, you will need to re-add the following Telerik No-XAML references to the project

Find these here: ...\Telerik\UI for Silverlight Q1 2014\Binaries.NoXaml
-Telerik.Windows.Controls
-Telerik.Windows.controls.Navigation

Find this here: ...\Telerik\UI for Silverlight Q1 2014\Themes.Implicit\OfficeBlack\Themes
-Telerik.Windows.Themes.Office_Black



Once the sample is running, you will see that the alert window starts with a question icon, then a thumbs-up icon if the user clicks Yes, a thumbs-down icon if the user clicks No and a cancel icon if the user clicks Cancel.

Here are the highlights:

-Using Implicit styling, reference a copy of the default style for RadConfirm (I highly recommend that you use Implicit Styling when you want to create custom implementations of the UI for Silverlight controls). Find this on MainPage.xaml in the Resources section.

-Create a new template for the Icon ContentPresenter, like this:

<ContentPresenter x:Name="Icon" VerticalAlignment="Top" Margin="16 8 8 8" ContentTemplate="{StaticResource BindableIconTemplate}"/>


-Bind the Image control's Source property to a ViewModel property. In my example, I do this:

<DataTemplate x:Key="BindableIconTemplate" >
            <StackPanel>
                <Image Source="{Binding WindowIconUriString, Source={StaticResource mainViewModel}}" />
            </StackPanel>
</DataTemplate>


-Then in the command's Execute method, you can do this to change the icon:

public void Execute(object parameter)
        {
            string source = Convert.ToString(parameter);
 
            var mainViewModel = Application.Current.Resources["mainViewModel"] as MainViewModel;
 
            if (mainViewModel == null)
            {
                return;
            }
 
            if (source == "Yes")
            {
                //If the user checks yes, change the icon to "thumbs up"
                mainViewModel.WindowIconUriString = "SuccessIcon.png";
            }
            else if (source == "No")
            {
                //if the user selected no, then change to the "thumbs down" icon
                mainViewModel.WindowIconUriString = "FailIcon.png";
            }
            else if(source == "Cancel")
            {
                //
                mainViewModel.WindowIconUriString = "CancelIcon.png";
            }
        }


Thank you for contacting Support and thank you for choosing Telerik.

Regards,
Lance
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Kashif
Top achievements
Rank 1
answered on 27 Jun 2014, 12:36 PM
Thanks this full fill my requirements.
Tags
Window
Asked by
Ivan Kopcanski
Top achievements
Rank 1
Answers by
George
Telerik team
Ivan Kopcanski
Top achievements
Rank 1
Jan
Top achievements
Rank 1
Denis Vuyka
Top achievements
Rank 1
Palak
Top achievements
Rank 1
Jozef
Top achievements
Rank 1
Ye
Top achievements
Rank 1
Kashif
Top achievements
Rank 1
Lance | Manager Technical Support
Telerik team
Share this question
or