Hi forum, probably this is a stupid issue but I cannot find a clue in the documentation: how comes that the grid does not refresh its display when its underlying data from a DataTable get changed? I describe here a dummy sample to reproduce my issue:
1) in a new WPF application I create a dummy datagrid with 2 fields only, one editable corresponding to a bool field and another non-editable corresponding to a string field:
<igDP:XamDataGrid VerticalAlignment="Stretch" DataSource="{Binding}" x:Name="_dgSample" Margin="2"> <igDP:XamDataGrid.FieldLayoutSettings> <igDP:FieldLayoutSettings AutoGenerateFields="False" HighlightAlternateRecords="True" AllowAddNew="False" AllowDelete="False"/> </igDP:XamDataGrid.FieldLayoutSettings> <igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout> <igDP:FieldLayout.Fields> <igDP:Field Name="selected" Label="sel."> <igDP:Field.Settings> <igDP:FieldSettings AllowEdit="True" CellWidth="40" LabelWidth="40" /> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="name" Label="name"> <igDP:Field.Settings> <igDP:FieldSettings AllowEdit="False" CellWidth="150" LabelWidth="150"/> </igDP:Field.Settings> </igDP:Field> </igDP:FieldLayout.Fields> </igDP:FieldLayout> </igDP:XamDataGrid.FieldLayouts></igDP:XamDataGrid>
2) in the load event I place this code to create a dummy data source in a DataTable object and bind the grid to it (_dt is a class member of type DataTable):
// create a dummy data table_dt = new DataTable("TSample");DataColumn col;
col = new DataColumn("selected", typeof(bool));col.AllowDBNull = false;col.DefaultValue = false;_dt.Columns.Add(col);
col = new DataColumn("name", typeof(string));col.AllowDBNull = false;col.DefaultValue = "";_dt.Columns.Add(col);
// fill it with some datafor (int i = 0; i < 10; i++){ DataRow row = _dt.NewRow(); row["selected"] = ((i & 1) != 0); row["name"] = i.ToString(); _dt.Rows.Add(row);} //efor_dt.AcceptChanges();
// bind to grid_dgSample.DataSource = new DataView(_dt, "", "name", DataViewRowState.CurrentRows);
When I run the sample I get the grid showing the data as expected. If now I click a button which simply inverts the boolean column value, the grid does not show any change:
for (int i = 0; i < _dt.Rows.Count; i++) _dt.Rows["selected"] = !(bool)_dt.Rows["selected"];_dt.AcceptChanges();
What I'm missing here? Thanx to all!
Thank you again, the link to the private message does not seem to work, but I can paste the whole application here. It's just a new WPF application created with Blend 2 December preview, as follows:
1) I create a new WPF application and add references to Infragistics3.Windows.DataPresenter.v.7.1.Express.dll, Infragistics3.Windows.Editors.v.7.1.Express.dll, Infragistics3.Windows.v.7.1.Express.dll. They are located in C:\Program Files\Infragistics\NetAdvantage for WPF (Express) 2007 Volume 1\Bin.
2) I insert a WPF XamDataGrid and use Blend UI to add a single field in its layout.
3) I run the application. Whenever I run it it crashes. If I open it in VS2008 the designer cannot open the window and underlines as errors the igDP: namespaced tags in XAML, as if I had not added the references. The full code for XAML and CS follows.
WINDOW1.XAML
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:igDP="http://infragistics.com/DataPresenter" xmlns:igEditors="http://infragistics.com/Editors" x:Class="InfraEx.Window1" x:Name="Window" Title="Window1" Width="640" Height="480">
<Grid x:Name="LayoutRoot"> <igDP:XamDataGrid HorizontalAlignment="Stretch" Margin="2,2,2,2" x:Name="_dgResults" VerticalAlignment="Stretch"> <igDP:XamDataGrid.FieldLayoutSettings> <igDP:FieldLayoutSettings AllowAddNew="False" AllowDelete="False" AutoGenerateFields="False" HighlightAlternateRecords="True"/> </igDP:XamDataGrid.FieldLayoutSettings> <igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout> <igDP:FieldLayout.Fields> <igDP:Field Name="name" Label="name"> <igDP:Field.Settings> <igDP:FieldSettings AllowEdit="False" CellWidth="100" LabelWidth="100"/> </igDP:Field.Settings> </igDP:Field> </igDP:FieldLayout.Fields> </igDP:FieldLayout> </igDP:XamDataGrid.FieldLayouts> </igDP:XamDataGrid> </Grid></Window>
WINDOW1.XAML.CS (no change from the wizard-generated code)
using System;using System.IO;using System.Net;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Media;using System.Windows.Media.Animation;using System.Windows.Navigation;
namespace InfraEx{ public partial class Window1 { public Window1() { this.InitializeComponent(); // Insert code required on object creation below this point. } }}
Any hint? Maybe the two versions (7.1 express + 7.2 Beta) do not like each other? Should I try 7.1 full evaluation?
The above stack trace indicates a field layout needs to be present - have you declared on in XAML? Unfortunately, I don't have the same environment as you (WPF 7.1 regular, and a interim build of 7.2). However, if you want me to have a peek at your code, you can send me a sample. I'll send you my email via private message.
Cheers,
Philipp
Thanks, so I should assume that the behaviour I noticed is a bug? Also, I've installed the 7.1 Express and replaced the references in the test project. Once recompiled when I launch it it simply throws an exception (details below); the same happens even if I create a new application from scratch with Blend2 (December 2007 preview) and insert a grid into its window and launch the application. Is there anything I should do besides changing the references? Or should I install the 7.1 non-express version?
System.ArgumentNullException was unhandled Message="Value cannot be null.\r\nParameter name: fieldLayout" Source="Infragistics3.Windows.DataPresenter.v7.1.Express" ParamName="fieldLayout" StackTrace: at Infragistics.Windows.Automation.Peers.DataPresenter.HeaderAutomationPeer..ctor(FieldLayout fieldLayout, RecordListControlAutomationPeer listAutomationPeer) at Infragistics.Windows.Automation.Peers.DataPresenter.RecordListControlAutomationPeer.j() at Infragistics.Windows.Automation.Peers.DataPresenter.RecordListControlAutomationPeer.GetChildrenCore() at System.Windows.Automation.Peers.AutomationPeer.EnsureChildren() at System.Windows.Automation.Peers.AutomationPeer.UpdateChildren() at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree() at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree() at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree() at System.Windows.ContextLayoutManager.fireAutomationEvents() at System.Windows.ContextLayoutManager.UpdateLayout() at System.Windows.Interop.HwndSource.Process_WM_SIZE(UIElement rootUIElement, IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) at System.Windows.Interop.HwndSource.LayoutFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler) at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter) at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) at MS.Win32.UnsafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow) at System.Windows.Window.ShowHelper(Object booleanBox) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler) at System.Windows.Threading.DispatcherOperation.InvokeImpl() at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state) at System.Threading.ExecutionContext.runTryCode(Object userData) at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Windows.Threading.DispatcherOperation.Invoke() at System.Windows.Threading.Dispatcher.ProcessQueue() at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler) at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter) at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg) at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame) at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame) at System.Windows.Threading.Dispatcher.Run() at System.Windows.Application.RunInternal(Window window) at System.Windows.Application.Run(Window window) at System.Windows.Application.Run() at InfraDummy.App.Main() in D:\Projects\30\Test\InfraDummy\InfraDummy\obj\Debug\App.g.cs:line 0 at System.AppDomain._nExecuteAssembly(Assembly assembly, String[ args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[ args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException:
Yes, you can install both 7.1 and 7.2 on the same machine without any issues - the installer puts assemblies for both packages in the GAC.