/// <summary> /// The main application class. /// </summary> public partial class App { #region Constructor /// <summary> /// Initializes a new instance of <see cref="App" />. /// </summary> public App() { StyleManager.ApplicationTheme = new Windows8Theme(); InitializeComponent(); Windows8Palette.Palette.AccentColor = (Color)Resources["AccentColor"]; ConfigureCulture(); } #endregion #region Private Methods /// <summary> /// Configures the culture for the application. /// </summary> private static void ConfigureCulture() { // set the default culture to English (AU) // ReSharper disable UseObjectOrCollectionInitializer var culture = new CultureInfo("en-AU"); // ReSharper restore UseObjectOrCollectionInitializer // long date format is used on date controls ("D") culture.DateTimeFormat.LongDatePattern = "ddd d-MMM-yyyy"; // short date format is used in grids ("d") culture.DateTimeFormat.ShortDatePattern = "dd-MMM-yy"; Thread.CurrentThread.CurrentCulture = culture; Thread.CurrentThread.CurrentUICulture = culture; } #endregion }<telerikDocking:RadSplitContainer Orientation="Horizontal" InitialPosition="DockedBottom"> <telerikDocking:RadPaneGroup> <!-- Modification Pane --> <TAS2DockingPanes:ModificationsPane x:Name="radPaneModifications" CanUserClose="False" CanDockInDocumentHost="False" IsHidden="{Binding Source={x:Static TAS2DockingPanes:VisibilitySettings.Instance}, Path=CanViewModificationsPane, Converter={StaticResource boolToReverseConverter}, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" /> <!-- Pricing Pane --> <TAS2DockingPanes:ExtrasPricingPane x:Name="radPanePricingExtras" CanUserClose="False" CanDockInDocumentHost="False" IsHidden="{Binding Source={x:Static TAS2DockingPanes:VisibilitySettings.Instance}, Path=CanViewExtrasPricingPane, Converter={StaticResource boolToReverseConverter}, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" /> </telerikDocking:RadPaneGroup></telerikDocking:RadSplitContainer>public class VisibilitySettings : INotifyPropertyChanged{ private static readonly VisibilitySettings instance = new VisibilitySettings(); private VisibilitySettings() { } public static VisibilitySettings Instance { get { return instance; } } private static bool m_canViewExtrasPricingPane; private static bool m_canViewModificationsPane; public static void SetVisibilitySettings(bool canViewExtrasPricingPane, bool canViewModificationsPane) { Instance.CanViewExtrasPricingPane = canViewExtrasPricingPane; Instance.CanViewModificationsPane = canViewModificationsPane; } public bool CanViewExtrasPricingPane { get { return m_canViewExtrasPricingPane; } set { m_canViewExtrasPricingPane = value; OnPropertyChanged(new PropertyChangedEventArgs("CanViewExtrasPricingPane")); } } public bool CanViewModificationsPane { get { return m_canViewModificationsPane; } set { m_canViewModificationsPane = value; OnPropertyChanged(new PropertyChangedEventArgs("CanViewModificationsPane")); } } //INotifyPropertyChanged Event public event PropertyChangedEventHandler PropertyChanged; public void OnPropertyChanged(PropertyChangedEventArgs e) { if (PropertyChanged != null) PropertyChanged(this, e); }}Hi
I am creating AggregateFunctions code-behind (see example code below). The CountFunction works but when I include a SumFunction the program crashes with the following error:
No generic method 'Sum' on type
'System.Linq.Enumerable' is compatible with the supplied type arguments. No type argiuments should be provided if the method is non-generic.
I can only see two possible explanations:
1. I am not setting the AggregateFunction properties correctly.
2. Setting Grid.ItemsSource to ObservableCollection<dynamic>
This collections data is correct since is working correctly when not using AggregateFunctions.
Is a dynamically created class a problem? The actual class properties are not dynamic but the actual system data types.
I am also using Grouping and it also works correctly. To make sure that grouping was not the problem I eliminated the grouping but the program still crashes.
---- The following is being looped ----
GridViewDataColumn dataCol = new GridViewDataColumn();
dataCol.DataMemberBinding = new Binding(column.ColumnName);
dataCol.Header = column.ColumnName;
dataCol.UniqueName = column.ColumnName;
dataCol.DataType = Type.GetType(column.SystemDataType);
dataCol.FilterMemberType = Type.GetType(column.SystemDataType);
--- Hard coded to test AggregateFunctions
if (dataCol.UniqueName == "Uid")
{
SumFunction sumFunction = new SumFunction();
sumFunction.SourceField = "Uid";
sumFunction.ResultFormatString = "Tot Uid: {0}";
sumFunction.SourceFieldType = Type.GetType(column.SystemDataType); // System.Int32
dataCol.AggregateFunctions.Add(sumFunction);
}
--- End hard coding ---
grid.Columns.Add(dataCol);
---- End of Loop ----
grid.ShowColumnFooters = true;
grid.ShowGroupFooters = true;
grid.ItemsSource = new QueryableCollectionView(clientData.Result);
Crashed at this point setting the ItemsSource.
Before putting in the SumFunction code everything was working correctly!
clientData.Result is ObservableCollection<dynamic>
====================================
If you don't have the answer could you provide the code-behind to create AggregrateFunctions. The following xaml snippet is from the WPF example Aggregates which is under the Grouping and Aggregates category. In looking at numerous past posts of this problem I think it would be most helpful to many developers to take the aggregate example and define the grid properties in code-behind. I would like to see a AggregateFunctions example that works using code-behind.
Thanks
Rich
<telerik:GridViewDataColumn Header="Freight"
DataMemberBinding="{Binding Freight, StringFormat=c}">
<telerik:GridViewDataColumn.AggregateFunctions>
<telerik:SumFunction SourceField="Freight" ResultFormatString="Total: {0:c}" />
</telerik:GridViewDataColumn.AggregateFunctions>
</telerik:GridViewDataColumn>
I am getting a pretty tough error that is coming from ItemsControlExtensions used by the TileList control. I get this error when I run the my application using Narrator.
I found an article about this on StackOverflow where somebody encountered this issue on some custom controls they had in their own solution that caused the error. But in my case, I am using Telerik. So I am kind of stuck unless Telerik fixes it.
Here is the link to the stack over flow find.
http://stackoverflow.com/questions/16245732/nullreferenceexception-from-presentationframework-dll
All I am trying to do is launch the app. The app uses a TileList control as well as a RadAutoCompleteBox, RadComboBox, and RadGridView.
When I run the app on Windows 8 I get two errors when the application starts:
First Error:
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.NullReferenceException
Stack:
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
at System.Windows.Application.RunInternal(System.Windows.Window)
at System.Windows.Application.Run()
Error 2:
Faulting application name: xxx.exe, version: 1.0.0.0, time stamp: 0x525495d8
Faulting module name: unknown, version: 0.0.0.0, time stamp: 0x00000000
Exception code: 0xc0000005
Fault offset: 0x000007fe546901ab
Faulting process id: 0x1e5c
Faulting application start time: 0x01cec47f37ad9317
Faulting application path: C:\Users\xxx\Desktop\xxx\Sprint1b\xxx.exe
Faulting module path: unknown
Report Id: 7f5853ab-3072-11e3-bef0-5c514f0c8fb3
Faulting package full name:
Faulting package-relative application ID:
I am able to run the app on Windows 7 and Windows 8.1 BUT when I run narrator on Windows 8.1 I get this error:
at Telerik.Windows.Controls.ItemsControlExtensions.<GetContainers>d__0`1.MoveNext() in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\Common\ItemsControlExtensions.cs:line 45
at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
at Telerik.Windows.Automation.Peers.RadAutoCompleteBoxAutomationPeer.GetChildrenCore() in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Controls\Input\AutoCompleteBox\AutomationPeers\RadAutoCompleteBoxAutomationPeer.cs:line 173
at System.Windows.Automation.Peers.AutomationPeer.EnsureChildren()
at System.Windows.Automation.Peers.AutomationPeer.GetChildren()
at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
at System.Windows.Automation.Peers.AutomationPeer.ValidateConnected(AutomationPeer connectedPeer)
at MS.Internal.Automation.ElementProxy.StaticWrap(AutomationPeer peer, AutomationPeer referencePeer)
at System.Windows.Automation.Peers.AutomationPeer.RaiseAutomationEvent(AutomationEvents eventId)
at System.Windows.Automation.Peers.SelectorAutomationPeer.RaiseSelectionEvents(SelectionChangedEventArgs e)
at System.Windows.Controls.Primitives.Selector.SelectionChanger.End()
at System.Windows.Controls.Primitives.Selector.SelectionChanger.SelectJustThisItem(ItemInfo info, Boolean assumeInItemsCollection)
at System.Windows.Controls.Primitives.Selector.OnSelectedIndexChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
at System.Windows.DependencyObject.SetCurrentValueInternal(DependencyProperty dp, Object value)
at System.Windows.Controls.TabControl.OnGeneratorStatusChanged(Object sender, EventArgs e)
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Windows.Controls.ItemContainerGenerator.SetStatus(GeneratorStatus value)
at System.Windows.Controls.ItemContainerGenerator.Generator.System.IDisposable.Dispose()
at System.Windows.Controls.Panel.GenerateChildren()
at System.Windows.Controls.Primitives.TabPanel.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Control.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Border.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Control.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.ContextLayoutManager.UpdateLayout()
at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
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)