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
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 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
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.
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.
George
the Telerik team
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?
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
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
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.
George
the Telerik team
I just changed Silverlight 4 to 5 and of course I changed referencies to newest version.
all the buttons became disable.
how to solve this problem?
You can find attached the modified sample. Hope this helps.
George
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
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.
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