11 Answers, 1 is accepted
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.
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.
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.
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.
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.
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 >>
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 ?
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,
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 >>
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.
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
Thanks Dinko,
Now, how can you close the dialog from within the command that is being executed from the custom button?
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