Hi
I have a ButtonTool inside a Ribbon control defined inside a ribbongroup. I want to set the button as default button when a user hits enter button on the window/texboxes present in it. The IsDefault property that is available in normal Button is not available in Button Tool. Can you suggest me a solution ?
Thanks
Eldin
Hi Eldin,
Let me know if you have any questions on this.
You can use InputBindings on the Window that watch for the Enter key to be pressed which will then execute a Command that you supply it. This way you won't have any events in code behind. You can then execute the code used in the ButtonTool's Click event inside the command.
<Window.InputBindings> <KeyBinding Key="Enter" Command="{Binding Path=MyCommand}"/></Window.InputBindings>
Hi Rob,
Thanks for looking into the issue. Actually we are using PRISM-MVVM pattern in our application. So I cant have any events defined in my code behind. Can you tell me if this is possible using Attached/Dependency Properties so that I will confirm with the MVVM standards ?
For this I'd imagine you could use the PreviewKeyDown event on the window itself to know when the user has pressed the Enter key and then use the RaiseEvent method to fire the ButtonTool's Click event. I'm putting together a sample to test this but it should meet your requirements. I'll have an update for you by Thursday.