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; } } }
}
You can attach a sample project using the Options tab on the reply form.
Looking forward to looking into your sample project.
Well there are a few questions i'd ask because it does not seem very clean to me but it should work. ;-)
Hello KarlMichael,
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.
Kind regards,
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?