HasErrors checkbox in DataForm

Dec 26, 2011 at 5:40 PM

Hello Tony!

When I try to use your toolkit with DataForm I have an unnecessary HasErrors checkbox on it. What am I doing wrong?

This is model (fragment):

   public class Customer : ModelBase<Customer>, IEditableObject
    {
        private string _id;
        [Display(AutoGenerateField = false)]
        public string Id
        {
            get { return _id; }
            set
            {
                _id = value;
                NotifyPropertyChanged(m => m.Id);
            }
        }

        private string _code;
        public string Code
        {
            get { return _code; }
            set
            {
                _code = value;
                NotifyPropertyChanged(m => m.Code);
            }
        }

 and this is xaml

<UserControl x:Class="mms.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400" xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit">

    <Grid x:Name="LayoutRoot" Background="White">
        <toolkit:DataForm Height="214" HorizontalAlignment="Left" Margin="51,52,0,0" Name="dataForm1" VerticalAlignment="Top" Width="306"
                          AutoGenerateFields="True" AutoCommit="False" Header="Head" AutoEdit="False"/>
    </Grid>
</UserControl>

and finally ctor

        public MainPage()
        {
            InitializeComponent();

            var customers=new ObservableCollection<Customer>();
            customers.Add(new Customer { Code = "1", Id = Guid.NewGuid().ToString(), Name = "Some name" });
            dataForm1.ItemsSource = customers;
            //dataForm1.
        }

Thanks in advance for your answer

 

Dec 29, 2011 at 1:33 AM

Hi gem,

The HasError is a public property in ModelBase, that you have derived your model from. You can probably go into your designer and delete the checkbox if you don't need it. This property checks where the model has any errors during validation.

Hope this helps.