RadAlert or RadConfirm with yes-no-cancel

17 posts, 0 answers
  1. Ivan Kopcanski
    Ivan Kopcanski avatar
    47 posts
    Member since:
    Jul 2009

    Posted 15 Jun 2010 Link to this post

    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
  2. George
    Admin
    George avatar
    1332 posts

    Posted 17 Jun 2010 Link to this post

    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
  3. DevCraft banner
  4. Ivan Kopcanski
    Ivan Kopcanski avatar
    47 posts
    Member since:
    Jul 2009

    Posted 26 Jul 2010 Link to this post

    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. 
  5. George
    Admin
    George avatar
    1332 posts

    Posted 29 Jul 2010 Link to this post

    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
  6. Ivan Kopcanski
    Ivan Kopcanski avatar
    47 posts
    Member since:
    Jul 2009

    Posted 31 Jul 2010 Link to this post

    Thanks :) This will cover my needs, I hope so.
  7. Jan
    Jan avatar
    58 posts
    Member since:
    May 2010

    Posted 05 Aug 2010 Link to this post

    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?
  8. George
    Admin
    George avatar
    1332 posts

    Posted 10 Aug 2010 Link to this post

    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
  9. Denis Vuyka
    Denis Vuyka avatar
    39 posts
    Member since:
    Oct 2009

    Posted 27 May 2011 Link to this post

    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?
  10. Denis Vuyka
    Denis Vuyka avatar
    39 posts
    Member since:
    Oct 2009

    Posted 27 May 2011 Link to this post

    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
  11. George
    Admin
    George avatar
    1332 posts

    Posted 02 Jun 2011 Link to this post

    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
  12. Palak
    Palak avatar
    1 posts
    Member since:
    Sep 2012

    Posted 15 Sep 2012 Link to this post

    thanks

  13. Jozef Cepel
    Jozef Cepel avatar
    1 posts
    Member since:
    Feb 2010

    Posted 26 Mar 2013 Link to this post

    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.
  14. Ye
    Ye avatar
    25 posts
    Member since:
    Aug 2012

    Posted 30 Apr 2013 Link to this post

    my solution became like this also.

    all the buttons became disable.

    how to solve this problem?
  15. George
    Admin
    George avatar
    1332 posts

    Posted 02 May 2013 Link to this post

    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.

  16. Kashif
    Kashif avatar
    3 posts
    Member since:
    Apr 2012

    Posted 17 Jun 2014 Link to this post

    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.
  17. Lance | Tech Support Engineer, Sr.
    Admin
    Lance | Tech Support Engineer, Sr. avatar
    135 posts

    Posted 19 Jun 2014 Link to this post

    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.
     
  18. Kashif
    Kashif avatar
    3 posts
    Member since:
    Apr 2012

    Posted 27 Jun 2014 in reply to Lance | Tech Support Engineer, Sr. Link to this post

    Thanks this full fill my requirements.
Back to Top
DevCraft banner