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

RadDataForm - Custom DataFormCommandProvider causes VS designer error

2 Answers 59 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 13 Nov 2013, 02:25 PM
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 Answers, 1 is accepted

Sort by
0
Jeff
Top achievements
Rank 1
answered on 13 Nov 2013, 03:33 PM
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.
0
Yoan
Telerik team
answered on 13 Nov 2013, 03:46 PM
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 >>
Tags
DataForm
Asked by
Jeff
Top achievements
Rank 1
Answers by
Jeff
Top achievements
Rank 1
Yoan
Telerik team
Share this question
or