Hi from germany,
i understand that i can execute DataPresenterCommans from within a Button_Clicked Eventhandler using the following Syntax:
private void Button_Click(object sender, System.Windows.RoutedEventArgs e){ xamGrid.ExecuteCommand(DataPresenterCommands.RecordFirstOverall);} However, this way the Button will not get disabled, when a Command is not available (Commands CanExecute() Method returns false). Is there a way to bind a Button DIRECTLY to a DataPresenter Command? button.Command = DataPresenterCommands.RecordFirstOverall;
private void Button_Click(object sender, System.Windows.RoutedEventArgs e){ xamGrid.ExecuteCommand(DataPresenterCommands.RecordFirstOverall);}
However, this way the Button will not get disabled, when a Command is not available (Commands CanExecute() Method returns false).
Is there a way to bind a Button DIRECTLY to a DataPresenter Command?
button.Command = DataPresenterCommands.RecordFirstOverall;
Hi Vjarai,
You can bind the button directly in XAML like this:
<Button
Command="{x:Static igDP:DataPresenterCommands.RecordFirstOverall}" CommandTarget="{Binding ElementName=xamGrid}" Content="RecordFirstOverall" Width="Auto" Height="20" HorizontalAlignment="Left"/>
You can see the example in the samples - Feature Browser -> XamDataGrid -> Data Binding and Interaction -> XamDataGrid Commands.
Sincerely,
Horen Kirazyan