Hi,
I tried to use Office 2010 Theme in my xamPivotGrid but got an exception. I copied Office2010Blue.xamPivotGrid.xaml from Infragistics sample into my project and wanted use it. Below is the exception info. Do you have any idea on this error: The resource file was not loaded properly when running the app? Or I missed something when trying to use it? Or there is a bug in the product?
I included this file as resource in my ptoject like:
<UserControl.Resources>
<ResourceDictionary
Source="/MyProject;component/Resources/Office2010Blue.xamPivotGrid.xaml" />
</UserControl.Resources>
Thanks for your help,
Joseph
==============================================================
System.NullReferenceException was unhandled Message=Object reference not set to an instance of an object. Source=InfragisticsWPF4.Controls.Grids.XamPivotGrid.v10.3 StackTrace: at Infragistics.Controls.Grids.PivotGridCellBase.get_ResolveStyle() at Infragistics.Controls.Grids.PivotCell.get_ResolveStyle() at Infragistics.Controls.Grids.PivotGridCellBase.ApplyStyle() at Infragistics.Controls.Grids.PivotGridCellBase.OnElementAttached(PivotGridCellControlBase element) at Infragistics.RecyclingContainer`1.Infragistics.ISupportRecycling.OnElementAttached(FrameworkElement elem) at Infragistics.RecyclingManager.PanelInfo.AttachElement(ISupportRecycling obj) at Infragistics.Controls.Grids.PivotPanelBase.RenderCell(PivotGridCellBase cell, Double availableWidth, Double availableHeight) at Infragistics.Controls.Grids.PivotDataRowsPanel.RenderEmptyCell() at Infragistics.Controls.Grids.PivotDataRowsPanel.MeasureOverride(Size availableSize) at System.Windows.FrameworkElement.MeasureCore(Size availableSize) at System.Windows.UIElement.Measure(Size availableSize) at Infragistics.Controls.Grids.PivotGridPanel.MeasureInternal(Size availableSize) at Infragistics.Controls.Grids.PivotGridPanel.MeasureOverride(Size availableSize) 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) 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) 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.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 System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV) 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 System.Windows.Controls.DockPanel.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.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.Run(Form mainForm) at Adapt2.ISO.ISOApp.Program.Main() in C:\MyProject\Program.cs:line 26
Hi Joseph,
I tried your case and I did not receive this exception. The theme was applied. What I see that is missing in your code is that the theme is not added like MergedDictionary. Please include this file like MergedDictionary:
<UserControl.Resources> <ResourceDictionary>
<ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="/Office2010Blue.xamPivotGrid.xaml"/> </ResourceDictionary.MergedDictionaries>
</ResourceDictionary> </UserControl.Resources>
Please try this and let us know if it works for you.
Regards,
Dimitrina
Hi Dimitrina:
I finally made it working after I added CellStyle definition for XamPivotGrid, such as below. May be it is because my app project is windows forms app and I only defined WPF pivot grid as a user control. So I did not load all the xaml files for brushes, styles, etc. into app at the start time. Or may be user needs to define cell style since 2010 them xaml file does not define them.
}"
="False">
Also I still have issue on how to load those xaml files into a traditional windows forms environment. I got exception once I tried to load 2010 Theme xaml file using below logic. My only option is to copy the contents to my user control xaml file.
private void DynamicLoadStyles2(string fileName)
{
if (File.Exists(fileName))
ResourceDictionary rd = (ResourceDictionary)XamlReader.Load(System.Xml.XmlReader.Create(fileName));
this.Resources.MergedDictionaries.Add(rd);
}
else
MessageBox.Show("File: " + fileName + " does not exist.");
Anyway, thanks a lot for your advise and suggestions.