Datawindow and Buttons

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


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?

Dec 13, 2012 at 11: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 2: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.

Dec 13, 2012 at 3:26 PM

Use this:

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

Jun 18, 2013 at 6:41 AM
Edited Jun 18, 2013 at 6:41 AM

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.
Jun 20, 2013 at 11: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 6:15 AM
Ok. But now I set the propertys IsDefault and IsCancek for the buttons and it works.
Jun 21, 2013 at 10:06 AM
Very nice, thanks for sharing.