This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
The DataGrid does not seem to pick up the current culture from the current thread. That is because I'm running a grid with dates here in the US, and they are displayed as dd/mm/yyyy instead of mm/dd/yyyy |
|
|
Hello Nestor In the next nightly build, the date time display and editor will use the current thread culture to format the strings. Jason Fauchelle |
|
|
It's fixed. Thanks. |
|
|
I'm having the same problem. Today we updated Mindscape.WpfElements.dll to version 6.0.2165.22593. The only difference I saw was that our datagrid column headers are now missing. Still don't have U.S. style mmddyy dates. In our XAML we've got: Everything in this project is dynamic. At compile time we don't know if our dashboard will contain a grid or what columns/rows the grid might have. So at runtime we define the columns in a DataTable like this: next we add our row data to the DataTable, then we do this:
dataGrid1.ItemsSource = table.DefaultView; to populate the grid. Is this the best way to go about it? Not sure why the dates still aren't US style and why the headers went away. Also is there a code-behind way to tell the datagrid to resize all columns after it is populated? We love the datagrid because it is fast. Thanks for your help, Scott Ferris |
|
|
Hello Scott The code you posted is the correct way to set the columns and items source. It sounds like you may not have the latest version. If you are using a trial, get the latest nightly build from here: http://www.mindscapehq.com/products/wpfelements/nightly-builds or if you have a paid version, get the latest nightly build from the store: http://www.mindscapehq.com/store/myaccount Make sure you uninstall the previous version first, and also make sure your project references the newly installed dll. Currently the only way to auto-size the columns is to set their width to be a GridLength with GridUnitType of Auto. Please note that this feature does affect performance as auto sizing can be expensive. The amount of performance affected depends on the number of columns in the grid. If you only want the auto sizing to occur once rather than constantly as the user scrolls, you can set the AutoColumnWidthBehavior on the DataGrid to OneTime. Jason Fauchelle |
|
|
Thanks Jason - much better now |
|
|
One more question - is there a way to resize the column widths, taking into account the header text? Our resize code looks like:
But the text on our column headers is still cut off. Are we doing this correctly & is there a way to resize the grid columns taking the header text into account as well? Thanks, Scott Ferris |
|
|
Hello Scott You are doing this correctly, but I have not been able to reproduce this issue at my end. Are the header strings only being clipped by a few pixels? or does it seem that the header string is not being considered in the calculation at all? Also please try this: when the application is running, drag the column resizer with the mouse to any width - this will turn off auto sizing. Then double click the column resizer to enable auto sizing again. Is the column header still clipped? or does it seem fine now? A couple of screen shots may help me deduce what is happening. Jason Fauchelle |
|
|
Thanks Jason - I'll check as soon as I can on the header resize. We had to go back to the older version because on the daily build from yesterday, the grid throws a null exception when using the horizontal scroll bar. I can get about 1/2 way across the grid (about 50 columns) and then it consistently throws the exception. Going back to the older version made the problem go away. Not sure if it's our bad data and the older grid handled it more gracefully or what. Error happens with Mindscape.WPFElements.dll version 6.0.2444.22919 But not with version 5.1.1944.22554 |
|
|
Hello This sounds like it could potentially be a bug in the DataGrid. I have not been able to reproduce this though. If you send me a repro project or at least a stack trace, then I'll work on fixing this up for you. Does this issue occur when all columns are auto-sizing, not-auto-sizing, or does it always occur? Jason Fauchelle |
|
|
Here's the stack trace, probably we don't have something set up correctly but not sure what. No problems with older version of Mindscape though. Thanks for any help you can give. at Mindscape.WpfElements.WpfDataGrid.ObjectFilterDescription..ctor(IPropertyInfo propertyInfo, IList values) at Mindscape.WpfElements.WpfDataGrid.ColumnFilter.#EKc() at Mindscape.WpfElements.WpfDataGrid.ColumnFilter..ctor(DataGridColumn column, Boolean useBooleanFilter) at Mindscape.WpfElements.WpfDataGrid.ColumnToColumnFilterConverter.Convert(Object value, Type targetType, Object parameter, CultureInfo culture) at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange) at System.Windows.Data.BindingExpression.Activate(Object item) at System.Windows.Data.BindingExpression.AttachToContext(AttachAttempt attempt) at System.Windows.Data.BindingExpression.MS.Internal.Data.IDataBindEngineClient.AttachToContext(Boolean lastChance) at MS.Internal.Data.DataBindEngine.Task.Run(Boolean lastChance) at MS.Internal.Data.DataBindEngine.Run(Object arg) at MS.Internal.Data.DataBindEngine.OnLayoutUpdated(Object sender, EventArgs e) at System.Windows.ContextLayoutManager.fireLayoutUpdateEvent() at System.Windows.ContextLayoutManager.UpdateLayout() at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg) at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork() at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks() at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget) at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, 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, Boolean ignoreSyncCtx) 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, Int32 numArgs) at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler) at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.RunDialog(Form form) at System.Windows.Forms.Form.ShowDialog(IWin32Window owner) at System.Windows.Forms.Form.ShowDialog() at FPS.Common.DefaultLogonForm.FPS.FPSLogon.ILogonInfo.ShowDialog() at FPS.FPSLogon.Logon.LogonToHostInternal(String AppName, String CIAName, IntPtr owner, Form FormOwner, Boolean AllowGatewayLogon, Boolean& DontWantLogon, String[] MoreCIANames) at FPS.FPSLogon.Logon.LogonToHost(String AppName, String CIAName, IntPtr owner, Form FormOwner) at WinFormParent.DummyCIM..ctor() in C:\Projects\FPSNet\VitalViewDashboard\WinFormParentTest\DummyCIM.cs:line 52 at WinFormParent.Program.Main() in C:\Projects\FPSNet\VitalViewDashboard\WinFormParentTest\Program.cs:line 28 at System.AppDomain.nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStartContext(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() |
|
|
Also - when I scroll horizontally, I'm just about to come to a column with boolean values. I'll test and replace with numeric 1 and 0 Thanks Scott |
|
|
Definitely something about the bool columns. I replaced them with strings "1" or "0" and the new mindscape works fine. Our code looks something like this:
column.Key is the heading, column.Value is the type - in this case, bool. Next we add the row data, like this, so our bool columns are getting either true or false value
|
|
|
Hello Thanks for the stack trace and the additional information, this has been a huge help to tracking down this issue! This will be fixed in the next nightly build. Jason Fauchelle |
|
|
Thanks for the help so far... We are back to working on the grid, and would like some auto size functionality for the columns. We call this function in the constructor for our window:
And our XAML contains this: AutoColumnWidthBehavior="Dynamic" Are we missing something? All the column widths are set to GridLength.Auto. We are running Mindscape.WPFElements.dll version 6.0.244.22919 Don't see any autosize behavior anywhere, not for header text, not for column data text. This is when the window first displays. I'm expecting the columns to be automatically sized based on the data without the user having to click on the resizer for each column. I can double click on the resizer and the column will resize. But I'm under the impression that this could be done via code, for all columns, when the window is displayed. Thanks, Scott Ferris |
|
|
Hello Scott It looks like you are using this feature correctly, but the behaviour you are seeing is definitely wrong. It may be a bug in the DataGrid. I'll investigate some time this week. Thanks for pointing this out. Jason Fauchelle |
|
|
Thanks again for brining this to our attention. This issue will be resolved in the next nightly build, so when you startup the application, all the columns will be auto sizing using the code you posted. Jason Fauchelle |
|
|
I'm seeing some column auto-size behavior, looking better. The resize is definitely taking column headers into account, that much is working when the grid first comes up. But the resize does not take into account the column data, unless I set the AutoColumnWidthBehavior="Dynamic" and move the scroll bar. Once I move the scroll bar, the column resizes. Is there a way to get the columns to resize based on header & column data when grid first comes up? We have to use AutoColumnWidthBehavior="OneTime" because Dynamic is too much of a performance hit. Even if the columns could just resize based on visible column data & not the entire column that would be great. My code still looks like:
The grid is in a UserControl derived class, and the above code is called from the UserControl Loaded event. Thanks for all your help, Scott Ferris |
|
|
Hello Scott Thanks for pointing this out and sorry we missed this. I'll get this fixed up for you first thing on Monday. Jason Fauchelle |
|
|
Hello Scott Thanks again for pointing this out. This bug has been resolved and the fix will be available in the next nightly build. Jason Fauchelle |
|