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

accessing the menu bar buttons

8 Answers 159 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 2
Jason asked on 30 Jun 2011, 12:16 AM
Hi

my aim is create my own ADD, Edit, Delete and Cancel outside the build in menu strip.

I am having trouble trying to execute the commands outside the build in menu strip buttons, just wondering if any one can give an example on how to execute the events.( ADD, Edit, Delete and cancel )

cheers

Jason

8 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 30 Jun 2011, 07:25 AM
Hi Jason,

You may benefit from the built-in commands of the RadDataForm. For example:

<StackPanel Grid.Row="1">
            <telerik:RadButton Content="Add" Command="telerik:RadDataFormCommands.AddNew" CommandTarget="{Binding ElementName=DataForm1}"/>
            <telerik:RadButton Content="BeginEdit" Command="telerik:RadDataFormCommands.BeginEdit" CommandTarget="{Binding ElementName=DataForm1}"/>
            <telerik:RadButton Content="Delete" Command="telerik:RadDataFormCommands.Delete" CommandTarget="{Binding ElementName=DataForm1}"/>
        </StackPanel>

 

Greetings,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jason
Top achievements
Rank 2
answered on 30 Jun 2011, 07:48 AM
cheers for the quick reply Maya

is there a way to access the command from the code behind?

cheers

Jason
0
Maya
Telerik team
answered on 30 Jun 2011, 07:59 AM
Hello Jason,

A command from the RadDataFormCommands can be defined and executed as follows:

private void RadButton_Click(object sender, RoutedEventArgs e)
        {
            var addNewCommand = RadDataFormCommands.AddNew as RoutedUICommand;
            addNewCommand.Execute(null, this.DataForm1);
        }

 

Regards,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jason
Top achievements
Rank 2
answered on 30 Jun 2011, 08:41 AM
Great thank you very much for the quick response

Jason
0
Jason
Top achievements
Rank 2
answered on 30 Jun 2011, 09:42 AM
Just one more question, is it possible to load up the dataform as a add new item, if it is possible can you please kindly post an example
cheers

Jason
0
Maya
Telerik team
answered on 30 Jun 2011, 01:34 PM
Hello Jason,

You may handle the Loaded event of the data form and call AddNewItem() method:

private void DataForm1_Loaded(object sender, RoutedEventArgs e)
        {
            this.DataForm1.AddNewItem();
        }

 

Kind regards,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jason
Top achievements
Rank 2
answered on 30 Jun 2011, 02:50 PM
Thanks for the solution, I am running into a problem, the add and delete button is disable when i load up the window, not sure why is doing this.
Jason
0
Jason
Top achievements
Rank 2
answered on 01 Jul 2011, 02:03 AM
I got it sorted but only the form part it doesn't actually write into the database I have bind it to itemessource cheers
Tags
DataForm
Asked by
Jason
Top achievements
Rank 2
Answers by
Maya
Telerik team
Jason
Top achievements
Rank 2
Share this question
or