accessing the menu bar buttons

9 posts, 0 answers
  1. Jason
    Jason avatar
    27 posts
    Member since:
    Jun 2011

    Posted 29 Jun 2011 Link to this post

    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
  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 30 Jun 2011 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Jason
    Jason avatar
    27 posts
    Member since:
    Jun 2011

    Posted 30 Jun 2011 Link to this post

    cheers for the quick reply Maya

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

    cheers

    Jason
  5. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 30 Jun 2011 Link to this post

    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
  6. Jason
    Jason avatar
    27 posts
    Member since:
    Jun 2011

    Posted 30 Jun 2011 Link to this post

    Great thank you very much for the quick response

    Jason
  7. Jason
    Jason avatar
    27 posts
    Member since:
    Jun 2011

    Posted 30 Jun 2011 Link to this post

    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
  8. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 30 Jun 2011 Link to this post

    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
  9. Jason
    Jason avatar
    27 posts
    Member since:
    Jun 2011

    Posted 30 Jun 2011 Link to this post

    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
  10. Jason
    Jason avatar
    27 posts
    Member since:
    Jun 2011

    Posted 30 Jun 2011 Link to this post

    I got it sorted but only the form part it doesn't actually write into the database I have bind it to itemessource cheers
Back to Top
UI for WPF is Visual Studio 2017 Ready