RadDataForm handle commit and cancel commands

3 posts, 0 answers
  1. Vladimir
    Vladimir avatar
    11 posts
    Member since:
    Oct 2010

    Posted 27 Jun 2011 Link to this post

    Hi,

    Is it possible to handle Commit and Cancel commands/events int the DataForm?

    I have dialog with RadDataForm(AutoEdit=TRUE). I wanna close this dialog when user click OK or Cancel button. How can i do this?
  2. Vladimir
    Vladimir avatar
    11 posts
    Member since:
    Oct 2010

    Posted 27 Jun 2011 Link to this post

    Here some sample of my code

    XAML
    <Window x:Class="Capture.Manager.Modules.EngineListing.Editor.AddEngineWindow"
            Height="300" Width="300">
        <Window.Resources>
            <RoutedCommand x:Key="CommitCommand"/>
            <RoutedCommand x:Key="CancelCommand"/>
        </Window.Resources>
        <Window.CommandBindings>
            <CommandBinding CanExecute="CommandBinding_CanExecute" Executed="CommandBinding_CommitExecuted" Command="{StaticResource CommitCommand}"/>
            <CommandBinding CanExecute="CommandBinding_CanExecute" Executed="CommandBinding_CancelExecuted" Command="{StaticResource CancelCommand}"/>
        </Window.CommandBindings>
        <Grid>
            <telerik:RadDataForm CurrentItem="{Binding}" x:Name="dataForm" CommandButtonsVisibility="All">
                <telerik:RadDataForm.CommitButtonStyle>
                    <Style TargetType="telerik:RadButton">
                        <Setter Property="Command" Value="{StaticResource CommitCommand}"/><!--do not work-->
                    </Style>
                </telerik:RadDataForm.CommitButtonStyle>
                <telerik:RadDataForm.CancelButtonStyle>
                    <Style TargetType="telerik:RadButton">
                        <Setter Property="Command" Value="{StaticResource CancelCommand}"/><!--do not work-->
                    </Style>
                </telerik:RadDataForm.CancelButtonStyle>
            </telerik:RadDataForm>
            <!--<Button Command="{StaticResource CommitCommand}"/>--><!--works-->
        </Grid>
    </Window>

    CS
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Shapes;
     
    namespace Capture.Manager.Modules.EngineListing.Editor
    {
        /// <summary>
        /// Interaction logic for AddEngineWindow.xaml
        /// </summary>
        public partial class AddEngineWindow : Window
        {
            public static RoutedCommand CommitCommand = new RoutedCommand();
     
            public AddEngineWindow()
            {
                InitializeComponent();
            }
     
            private void CommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
            {
                e.CanExecute = true;
            }
     
            private void CommandBinding_CommitExecuted(object sender, ExecutedRoutedEventArgs e)
            {
     
            }
     
            private void CommandBinding_CancelExecuted(object sender, ExecutedRoutedEventArgs e)
            {
     
            }
        }
    }

    DataContext
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Runtime.Serialization.Formatters.Binary;
    using System.IO;
     
    namespace Capture.Manager.Infrastructure.Objects
    {
        [Serializable]
        public class EngineMeta : ICloneable
        {
            public string Name { get; set; }
     
            public object Clone()
            {
                MemoryStream stream = new MemoryStream();
                BinaryFormatter f = new BinaryFormatter();
                f.Serialize(stream, f);
                return f.Deserialize(stream);
            }
        }
    }
  3. UI for WPF is Visual Studio 2017 Ready
  4. Vladimir
    Vladimir avatar
    11 posts
    Member since:
    Oct 2010

    Posted 27 Jun 2011 Link to this post

    My fault,

    EditEnded event thats what i need.

    Thank you for your product!
Back to Top