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

CloseRadWindow TriggerAction

1 Answer 85 Views
Window
This is a migrated thread and some comments may be shown as answers.
Joseph Gershgorin
Top achievements
Rank 1
Joseph Gershgorin asked on 25 Sep 2009, 05:20 AM
I found it a little annoying that I had to drop to code behind to just have a button do nothing more than close a RadWindow it. It's fairly easy to encapsulate this into TriggerAction.

For this to work you should have installed and referenced System.Windows.Interactivity from the Blend 3 SDK.

Here's the Behavior:
using System.Windows; 
using System.Windows.Interactivity; 
using Telerik.Windows.Controls; 
 
namespace Mass.ThirdParty.Telerik.Behaviors 
    public class CloseRadWindowTriggerAction : TriggerAction<FrameworkElement> 
    { 
        protected override void Invoke(object parameter) 
        { 
            var radWindow = RadWindow.GetParentRadWindow(AssociatedObject); 
 
            if (radWindow != null
            { 
                radWindow.Close(); 
            } 
        } 
    } 
 

And here's how to use it in XAML:
<Button Content="Close"
    <i:Interaction.Triggers> 
        <i:EventTrigger EventName="Click"
            <Behaviors:CloseRadWindowTriggerAction /> 
        </i:EventTrigger> 
    </i:Interaction.Triggers> 
</Button> 

1 Answer, 1 is accepted

Sort by
0
Miroslav Nedyalkov
Telerik team
answered on 25 Sep 2009, 12:55 PM
Hello Joseph,

Thank you for sharing your thoughts! If the button that should close the RadWindow is within the RadWindow control you may use "out of the box" the following approach to achieve the same result:
<Button Content="Close!"
    <telerik:CommandManager.InputBindings> 
        <telerik:InputBindingCollection> 
            <telerik:MouseBinding Gesture="LeftClick" 
                    Command="telerik:WindowCommands.Close" /> 
        </telerik:InputBindingCollection> 
    </telerik:CommandManager.InputBindings> 
</Button> 

Regards,
Miroslav Nedyalkov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Window
Asked by
Joseph Gershgorin
Top achievements
Rank 1
Answers by
Miroslav Nedyalkov
Telerik team
Share this question
or