I have bound a property defined as an IBindingList to an XAMDataGrid. The property is in the ViewModel assigned to that view. When the WPF form loads, it shows the correct data. If I click a button to load a different set of data, the correct method in the ViewModel is called and the IBindingList property is updated with the new records. But the XAMDataGrid never changes it's records. It still shows the first set of records.
Here's the bound property:
public
objLookupDataList
{
get
m_objLookupDataList;
}
set
m_objLookupDataList =
);
OnRaisePropertyChanged is in the base class; it owrks as proved by textboxes bound to properties on the same ViewModel calling base.RasePropertyChangedEvent
Here's the XAML XAMDataGrid:
<
igDP:XamDataGrid Margin="16,51,13,12" Name="dgLookupTable" TabIndex="2" FieldLayoutInitialized="dgLookupTable_FieldLayoutInitialized" DataSource="{Binding Path=objLookupDataList,ValidatesOnExceptions=True,UpdateSourceTrigger=PropertyChanged,NotifyOnValidationError=True,ValidatesOnDataErrors=True}" AutoFit="True" RecordUpdating="dgLookupTable_RecordUpdating" Grid.Row="1"></igDP:XamDataGrid>
Finally, here is the xaml code behind regardind the XAMDataGrid:
///
<summary>
/// Defines properites for the dgLookupTable grid.
/// </summary>
private void SetdgLookupTableDataGrid()
dgLookupTable.FieldLayoutSettings.AutoGenerateFields =
false;
dgLookupTable.FieldLayoutSettings.AllowAddNew =
true;
dgLookupTable.FieldLayoutSettings.AddNewRecordLocation =
AddNewRecordLocation.OnTopFixed;
dgLookupTable.FieldSettings.AllowEdit =
dgLookupTable.FieldLayoutSettings.AllowDelete =
dgLookupTable.UpdateMode =
UpdateMode.OnRecordChangeOrLostFocus;
dgLookupTable.FieldLayoutSettings.HighlightAlternateRecords =
dgLookupTable.FieldLayoutSettings.SelectionTypeCell =
SelectionType.Single;
dgLookupTable.FieldLayoutSettings.SelectionTypeRecord =
dgLookupTable.FieldSettings.CellClickAction =
CellClickAction.Default; ;
dgLookupTable.FieldSettings.CellContentAlignment =
CellContentAlignment.LabelAboveValueAlignCenter;
dgLookupTable.FieldSettings.LabelTextAlignment = System.Windows.
TextAlignment.Center;
dgLookupTable.FieldSettings.AllowRecordFiltering =
dgLookupTable.IsNestedDataDisplayEnabled =
dgLookupTable.FieldLayoutSettings.SupportDataErrorInfo =
SupportDataErrorInfo.RecordsAndCells;
dgLookupTable.FieldLayoutSettings.DataErrorDisplayMode =
DataErrorDisplayMode.ErrorIconAndHighlight;
// bind a property to the Visibility property
//System.Windows.Visibility SFWHoldingFacilitiesGridVisibility = Model.dgLookupGridVisibility;
//Binding dgLookupGridVisibilityBinding = new Binding("dgLookupGridVisibility");
//SFWHoldingFacilitiesGridVisibilityBinding.Source = Model;
//SFWHoldingFacilitiesGridVisibilityBinding.Mode = BindingMode.Default;
//dgLookupTable.SetBinding(XamDataGrid.VisibilityProperty, dgLookupGridVisibilityBinding);
//this.dgLookupTable.Visibility = System.Windows.Visibility.Visible;
/// <summary>
/// Defines the fields layout for the dgLookupTable grid.
/// <param name="sender"></param>
/// <param name="e"></param>
private void dgLookupTable_FieldLayoutInitialized(object sender, Infragistics.Windows.DataPresenter.Events.FieldLayoutInitializedEventArgs e)
FieldSettings fs = null;
Field CodeField = new Field();
CodeField.Visibility =
Visibility.Visible;
fs =
new FieldSettings();
fs.AllowHiding =
AllowFieldHiding.Never;
fs.AllowRecordFiltering =
fs.AllowResize =
fs.CellMinHeight = 23;
fs.CellMinWidth = 250;
CodeField.Settings = fs;
CodeField.Name =
"Code";
CodeField.Label =
LookupsResources.ResourceManager.GetString("Code", CultureInfo.CurrentUICulture);
CodeField.Width =
new FieldLength(100);
CodeField.IsScrollTipField =
Field DescriptionField = new Field();
DescriptionField.Visibility =
DescriptionField.Settings = fs;
DescriptionField.Name =
"Description";
DescriptionField.Label =
LookupsResources.ResourceManager.GetString("Description", CultureInfo.CurrentUICulture);
DescriptionField.Width =
DescriptionField.IsScrollTipField =
e.FieldLayout.Fields.Add(CodeField);
e.FieldLayout.Fields.Add(DescriptionField);
Alex,
Thanks for the sample. I was also having problems with the UI not updating. Reviewing your code showed me where I didn't implement INotifyChange at the business object level.
Bob
Hello,
I was not able to reproduce this behavior. Please note that the XamDataGrid is listening to the collection changed event of the IBindingList and you just have to clear the items and add new ones. You do not have to create a new object.
If you really have to do that, the XamDataGrid should still pick up the property change. I have attached my an isolated sample for reference.