Hi,
i guess this is a bug report for XamDataGrid.
I successfully displayed a row error using IDataErrorInfo.Error property setting FieldLayoutSettings.SupportDataErrorInfo to "RecordsAndCells".
Also the change notification with PropertyChanged(String.Empty) works.
BUT: It only works if AutoGenerateColumns is set to true. If it is set to false, the row error is still displayed. But the XamDataGrid won't react on the property change.
This does not really make sense to me.
Regards,
Karl-Michael Beck
Hello Karl-Michael Beck,
I have been looking into your issue and in order to test this out I whipped up a small test sample (Grid_IDataError_row_border.zip) where everything seems to work as expected with the UnboundFields. Please look into the attachment I have created for you and let me know if there is anything I am missing, or if this solved you issue.
Looking forward to hearing from you.
Hi, im sending another example where the error occurs. Is it somehow possible for me to attach a zip file anway?
Set the aShowError variable to true to see what's not working.
Set the aShowError variable to false to see what's working.
The issue is i think that i do not have a column change that makes the row error disappear.
(Sorry for the formating but the copy paste just don't work so well)
MainWindow.xaml
<Window x:Class="DataErrorInfoProblem2.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525" xmlns:igDP="http://infragistics.com/DataPresenter"> <Grid> <StackPanel Orientation="Vertical"> <Button Click="Button_Click" >hit me</Button> <igDP:XamDataGrid HorizontalAlignment="Left" Name="xamDataGrid1" RecordContainerGenerationMode="LazyLoad" > <igDP:XamDataGrid.FieldLayoutSettings> <igDP:FieldLayoutSettings SupportDataErrorInfo="RecordsAndCells"/> </igDP:XamDataGrid.FieldLayoutSettings> </igDP:XamDataGrid> </StackPanel> </Grid> </Window>
---------------------------------------------------------------------------
MainWindow.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.Navigation; using System.Windows.Shapes;
namespace DataErrorInfoProblem2 { /// <summary> /// Interaktionslogik für MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); bool aShowProblem = true; this.xamDataGrid1.FieldLayoutSettings.AutoGenerateFields = !aShowProblem; this.xamDataGrid1.DataSource = new CRecord[] { this.Record }; }
private CRecord Record = new CRecord();
private void Button_Click(object sender, RoutedEventArgs e) { if(this.Record.Error == string.Empty) { this.Record.Error = "TestError"; } else { this.Record.Error = String.Empty; } } }
public class CRecord : System.ComponentModel.IDataErrorInfo, System.ComponentModel.INotifyPropertyChanged { public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
private string ErrorM = "TestError"; public string Error { set { this.ErrorM = value; if (null != this.PropertyChanged) { this.PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs("")); } } get { return this.ErrorM; } }
public string this[string aName] { get { return string.Empty; } } }
}
Hi, here's the file. :)
i can not add a zip file. if i do so an unexpected error page is displayed.
Hello KarlMichael,
Excuse me for the late reply, there seems to have some trouble with the community forum when you tried posting, which is now resolved. Please try and attach this again.
Hello Petar,
here is the zip file. Set the aShowError variable to false to see it working. aShowError = True shows the error case.
Kind regards,
Karl-Michael
Hi Karl-Michael,
I have been looking into the sample project that you have attached and have found the cause of the behavior you described. I initially noticed that the Error field’s PropertyChanged line never gets executed, which is the reason for the XamDataGrid not knowing there is an update. The reason this is caused only when the AutoGenerateFields is set to false is because, then no binding is created for the underlying object CRecord. If there is no binding the PropertyChanged is always null and no notification occurs. If you are to create on property that is to be bound to a Field the IDataErrorInfo will still work with the AutoGenerateFields set to false. I have modified your sample to illustrate this (DataErrorInfoProblem2_FIXED.zip)
Please let me know, if you require any further clarification on the matter.
Well there are a few questions i'd ask because it does not seem very clean to me but it should work. ;-)
I have modified the sample, so now it works as expected. Basically I used UnboundField’s BindingPath Property instead of Binding one and I also change the Name of the UnboundField, because when it is the same as the name of a property of the underlying object the grid doesn’t work properly.
Hope this helps you.
i had a look at the example but it doesnt fit my needs because i use unbound fields. I have modified the last example of peter to use unbound fields and the problem occurs again.
kmb
Hello Karl-Michael,
Did you have the chance to look into the sample Peter attached (DataErrorInfoProblem2_FIXED), becasue it seems like that it works as you want. If it doesn't satisfies all your requirements, could please be more specific what do you want to achieve.
Looking forward for your reply.
I have an row error but i do not display the cell that's causing the error as a single grid column. That's why it will become difficult to assign the error to a cell.
As far as i see there is a event PRopertyChanged(String.Empty) which i think is for the row error. At least this is how i interpreted all the examples i saw with PropertyChanged(String.empty)
Independent of that a property change with an property name given should refresh the cell error.
I'm afraid this will result in a workaround to display a cell with 0 width and allow columnresize set to 0. Will this work?