Datawindow and Buttons

Topics: Questions
Dec 13, 2012 at 6:32 AM
Edited Dec 13, 2012 at 6:32 AM

Hello

Have a Datawindow with my own style. On this Datawindow there are 3 Buttons. Ok and Cancel and one Custombutton with my own command.

Are there  Commands for the Ok and Cancel Button or do I have to define them for me?

Coordinator
Dec 13, 2012 at 10:35 AM

You can also specify commands. You can simply specify the OnOKCanExecute and OnOKExecute methods inside the DataWindow to create the commands.

Dec 13, 2012 at 1:47 PM

Yes thats clear. But my question was do I have to define a command. Or is there a other solution. Something that calls CloseViewModel(true) or CloseViewModel(false). So I don't have to define my own commands.

Coordinator
Dec 13, 2012 at 2:26 PM

Use this:

AddCustomButton(new DataWindowButton("OK", OnOkExecute, OnOkCanExecute));

Jun 18, 2013 at 5:41 AM
Edited Jun 18, 2013 at 5:41 AM
Hello.

Can I ask one more question to in this discussion.

I need my own design. So I added buttons in xaml. And also added two Commands:
public Command CancelCommand { get; private set; }

public Command OkCommand { get; private set; }
but I also wan't to catch the keys: esc and enter.

At the moment when I press esc the window only close with. No command is executed.
Coordinator
Jun 20, 2013 at 10:16 AM
Override the OnKeyDown yourself in the window and call your commands. You can take a look at the actual implementation how we did it.
Jun 21, 2013 at 5:15 AM
Ok. But now I set the propertys IsDefault and IsCancek for the buttons and it works.
Coordinator
Jun 21, 2013 at 9:06 AM
Very nice, thanks for sharing.