RadDataForm - Custom DataFormCommandProvider causes VS designer error

3 posts, 0 answers
  1. Jeff
    Jeff avatar
    39 posts
    Member since:
    Jun 2013

    Posted 13 Nov 2013 Link to this post

    I have a RadDataForm that's using a custom DataFormCommandProvider - pretty much lifted from the documentation.  However, as soon as I assign my custom provider to the "CommandProvider" property to the RadDataForm, the VS designer places an error panel over the top of my rendered control with the following message:

    "An object of the type "TruNest.Client.CustomCommandProvider" cannot be applied to a property that expects the type "Telerik.Windows.Controls.ICommandProvider".

    The project builds and runs fine, and the custom command provider works as expected.  However, the designer definitely has problems with it for some reason.  Here is a XAML code (snippet) for the RadDataForm:

       <UserControl.Resources>
           <local:CustomCommandProvider x:Key="CustomProvider" />
       </UserControl.Resources>
           
    <telerik:RadDataForm x:Name="dataForm"
                                HorizontalAlignment="Stretch"
                                VerticalAlignment="Stretch"
                                AutoGeneratingField="dataForm_AutoGeneratingField"
                                CommandButtonsVisibility="All"
                                CommandProvider="{StaticResource CustomProvider}"
                                EditEnded="dataForm_EditEnded"
                                IsEnabled="{Binding IsEnabled}"
                                ItemsSource="{Binding TableData}" />

    And the source for the CustomCommandProvider class (again, pretty much straight from the docs):

    using Telerik.Windows.Controls;
    using Telerik.Windows.Controls.Data.DataForm;
     
    namespace TruNest.Client
    {
        public class CustomCommandProvider : DataFormCommandProvider
        {
            public CustomCommandProvider()
                : base(null)
            {
            }
     
            public CustomCommandProvider(RadDataForm dataForm)
                : base(dataForm)
            {
                this.DataForm = dataForm;
            }
     
            protected override void CommitEdit()
            {
                bool? dialogResult = null;
                RadWindow.Confirm(new DialogParameters()
                {
                    Header = "Confirm",
                    Content = "Commit all changes?",
                    Closed = (confirmDialog, eventArgs) =>
                    {
                        dialogResult = eventArgs.DialogResult;
                    }
                });
     
                if ((bool)dialogResult)
                {
                    this.DataForm.CommitEdit();
                }
            }
     
            protected override void CancelEdit()
            {
                bool? dialogResult = null;
                RadWindow.Confirm(new DialogParameters()
                {
                    Header = "Confirm",
                    Content = "Cancel all changes?",
                    Closed = (confirmDialog, eventArgs) =>
                    {
                        dialogResult = eventArgs.DialogResult;
                    }
                });
     
                if ((bool)dialogResult)
                {
                    this.DataForm.CancelEdit();
                }
            }
     
            protected override bool CanDeleteExecute()
            {
                return false;
            }
     
            protected override bool CanAddNewExecute()
            {
                return false;
            }
        }
    }

    How can I eliminate the VS designer error so I can *see* my control instead of the error message?

    Jeff
  2. Jeff
    Jeff avatar
    39 posts
    Member since:
    Jun 2013

    Posted 13 Nov 2013 Link to this post

    One thing I didn't mention in the OP.  This issue is somewhat erratic.  That is, sometimes (though rarely), the problem just goes away and the designer renders the control correctly (without me changing any related code).  Generally, that's not the case and it renders with the mentioned error message.  It's unclear to me what causes the variation.  Using VS 2012 if it matters.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Yoan
    Admin
    Yoan avatar
    1068 posts

    Posted 13 Nov 2013 Link to this post

    Hello Jeff,

    Indeed, this is strange. We are not aware of such an issue with the latest Telerik controls version. I've tried to reproduce the problem you report, but to no avail. I have attached my test project for a reference.

    Regards,
    Yoan
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top