Hi,
using XamDataGrid I get the following error: "Recursive call to Automation Peer API is not valid"
What I can say at the moment is, that this happens only on some Win XP machines.
What I do is the following:
During runtime I add a new tab to XamTabControl. The content of that tab is a view containing a XamDataGrid.
Stacktrace:
at System.Windows.Markup.XamlReader.RewrapException(Exception e, Uri baseUri) at System.Windows.FrameworkTemplate.LoadTemplateXaml(XamlReader templateReader, XamlObjectWriter currentWriter) at System.Windows.FrameworkTemplate.LoadTemplateXaml(XamlObjectWriter objectWriter) at System.Windows.FrameworkTemplate.LoadOptimizedTemplateContent(DependencyObject container, IComponentConnector componentConnector, IStyleConnector styleConnector, List`1 affectedChildren, UncommonField`1 templatedNonFeChildrenField) at System.Windows.FrameworkTemplate.LoadContent(DependencyObject container, List`1 affectedChildren) at System.Windows.StyleHelper.ApplyTemplateContent(UncommonField`1 dataField, DependencyObject container, FrameworkElementFactory templateRoot, Int32 lastChildIndex, HybridDictionary childIndexFromChildID, FrameworkTemplate frameworkTemplate) at System.Windows.FrameworkTemplate.ApplyTemplateContent(UncommonField`1 templateDataField, FrameworkElement container) at System.Windows.FrameworkElement.ApplyTemplate() 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 Infragistics.Windows.Controls.CardPanel.MeasureOverride(Size availableSize) at System.Windows.FrameworkElement.MeasureCore(Size availableSize) at System.Windows.UIElement.Measure(Size availableSize) at System.Windows.Controls.Control.MeasureOverride(Size constraint) at Infragistics.Windows.DataPresenter.DataItemPresenter.MeasureOverride(Size availableSize) at Infragistics.Windows.DataPresenter.CellValuePresenter.MeasureOverride(Size availableSize) at System.Windows.FrameworkElement.MeasureCore(Size availableSize) at System.Windows.UIElement.Measure(Size availableSize) at Infragistics.Windows.DataPresenter.VirtualizingDataRecordCellPanel.TryGetPreferredExtent(FieldLayoutItemBase fieldLayoutItem, Boolean cell, Boolean width, Double& extent) at Infragistics.Windows.DataPresenter.CellLayoutItem.GetSize(LayoutItemSize size) at Infragistics.Windows.DataPresenter.LayoutItem.Infragistics.Controls.Layouts.Primitives.ILayoutItem.get_PreferredSize() at Infragistics.Controls.Layouts.Primitives.GridBagLayoutManager.GridBagConstraintCache..ctor(ILayoutItem item, IGridBagConstraint gc) at Infragistics.Controls.Layouts.Primitives.GridBagLayoutManager.GetGridBagCacheHelper(GridBagConstraintCache[]& tmpGccArr) at Infragistics.Controls.Layouts.Primitives.GridBagLayoutManager.CalculateGridBagLayout() at Infragistics.Controls.Layouts.Primitives.GridBagLayoutManager.CalculatePreferredSize(ILayoutContainer container, Object containerContext) at Infragistics.Windows.DataPresenter.FieldGridBagLayoutManager.CalculatePreferredSize() at Infragistics.Windows.DataPresenter.VirtualizingDataRecordCellPanel.MeasureOverride(Size availableSize) 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 Infragistics.Windows.Controls.CardPanel.MeasureOverride(Size availableSize) at System.Windows.FrameworkElement.MeasureCore(Size availableSize) at System.Windows.UIElement.Measure(Size availableSize) at System.Windows.Controls.Control.MeasureOverride(Size constraint) at Infragistics.Windows.DataPresenter.DataRecordCellArea.MeasureOverride(Size availableSize) 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 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.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 Infragistics.Windows.Controls.CardPanel.MeasureOverride(Size availableSize) at System.Windows.FrameworkElement.MeasureCore(Size availableSize) at System.Windows.UIElement.Measure(Size availableSize) at System.Windows.Controls.Control.MeasureOverride(Size constraint) at Infragistics.Windows.DataPresenter.RecordPresenter.MeasureOverride(Size availableSize) at System.Windows.FrameworkElement.MeasureCore(Size availableSize) at System.Windows.UIElement.Measure(Size availableSize) at Infragistics.Windows.DataPresenter.GridViewPanelFlat.GenerationCache.GenerateNextElement(Boolean isHeader) at Infragistics.Windows.DataPresenter.GridViewPanelFlat.GenerationCache.GenerateRecordsHelper() at Infragistics.Windows.DataPresenter.GridViewPanelFlat.GenerationCache.GenerateTopFixedRecords() at Infragistics.Windows.DataPresenter.GridViewPanelFlat.GenerationCache.GenerateAllRecords() at Infragistics.Windows.DataPresenter.GridViewPanelFlat.MeasureOverride(Size availableSize) at System.Windows.FrameworkElement.MeasureCore(Size availableSize) at System.Windows.UIElement.Measure(Size availableSize) at System.Windows.ContextLayoutManager.UpdateLayout() at System.Windows.UIElement.UpdateLayout() at Infragistics.Windows.Automation.Peers.XamTabControlAutomationPeer.GetChildrenCore() 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.ValidateConnected(AutomationPeer connectedPeer) at System.Windows.Automation.Peers.AutomationPeer.AutomationPeerFromInputElement(IInputElement focusedElement) at System.Windows.Automation.Peers.AutomationPeer.RaiseFocusChangedEventHelper(IInputElement newFocus) at System.Windows.Input.KeyboardDevice.ChangeFocus(DependencyObject focus, Int32 timestamp) at System.Windows.Input.KeyboardDevice.TryChangeFocus(DependencyObject newFocus, IKeyboardInputProvider keyboardInputProvider, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed) at System.Windows.Input.KeyboardDevice.Focus(DependencyObject focus, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed) at System.Windows.Input.KeyboardDevice.Focus(IInputElement element) at System.Windows.UIElement.Focus() at System.Windows.Controls.TabItem.SetFocus() at System.Windows.Controls.TabControl.OnSelectionChanged(SelectionChangedEventArgs e) at Infragistics.Windows.Controls.XamTabControl.OnSelectionChanged(SelectionChangedEventArgs e) at System.Windows.Controls.Primitives.Selector.InvokeSelectionChanged(List`1 unselectedItems, List`1 selectedItems) at System.Windows.Controls.Primitives.Selector.SelectionChanger.End() at System.Windows.Controls.Primitives.Selector.SetSelectedHelper(Object item, FrameworkElement UI, Boolean selected) at System.Windows.Controls.Primitives.Selector.NotifyIsSelectedChanged(FrameworkElement container, Boolean selected, RoutedEventArgs e) at System.Windows.Controls.Primitives.Selector.OnSelected(Object sender, RoutedEventArgs e) at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e) at Infragistics.Windows.Controls.TabItemEx.OnSelected(RoutedEventArgs e) at System.Windows.Controls.TabItem.OnIsSelectedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at Infragistics.Windows.Controls.TabItemEx.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.TabItem.OnPreviewGotKeyboardFocus(KeyboardFocusChangedEventArgs e) at Infragistics.Windows.Controls.TabItemEx.OnPreviewGotKeyboardFocus(KeyboardFocusChangedEventArgs e) at System.Windows.UIElement.OnPreviewGotKeyboardFocusThunk(Object sender, KeyboardFocusChangedEventArgs e) at System.Windows.Input.KeyboardFocusChangedEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget) at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args) at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted) at System.Windows.Input.InputManager.ProcessStagingArea() at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input) at System.Windows.Input.KeyboardDevice.TryChangeFocus(DependencyObject newFocus, IKeyboardInputProvider keyboardInputProvider, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed) at System.Windows.Input.KeyboardDevice.Focus(DependencyObject focus, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed) at System.Windows.Input.KeyboardDevice.Focus(IInputElement element) at System.Windows.UIElement.Focus() at Roesberg.WebDocumentation.UI.Views.WebDokuNavigationView.OpenDocumentInTab(WebDokuDocument document, TabItemEx tabItem) in d:\Entwickl\RCC\V1\RCC\Roesberg.WebDocumentation.UI\Views\WebDokuNavigationView.xaml.cs:line 337 at Roesberg.WebDocumentation.UI.Views.WebDokuNavigationView._vm_OpenWebDokuDocument(Object sender, DocumentEventArgs e) in d:\Entwickl\RCC\V1\RCC\Roesberg.WebDocumentation.UI\Views\WebDokuNavigationView.xaml.cs:line 288 at Roesberg.WebDocumentation.Core.ViewModels.WebDokuNavigationViewModel.OnOpenWebDokuDocument(DocumentEventArgs args) in d:\Entwickl\RCC\V1\RCC\Roesberg.WebDocumentation.Core\ViewModels\WebDokuNavigationViewModel.cs:line 629 at Roesberg.WebDocumentation.Core.ViewModels.WebDokuNavigationViewModel.OpenDocument(CboNodes webDokuNode) in d:\Entwickl\RCC\V1\RCC\Roesberg.WebDocumentation.Core\ViewModels\WebDokuNavigationViewModel.cs:line 945 at Roesberg.WebDocumentation.Core.ViewModels.WebDokuNavigationViewModel.TreeVM_ItemDoubleClicked(Object sender, RBTreeNodeDoubleClickedEventArgs e) in d:\Entwickl\RCC\V1\RCC\Roesberg.WebDocumentation.Core\ViewModels\WebDokuNavigationViewModel.cs:line 857 at Roesberg.TreePropSheet.Core.ViewModels.RBTree.RBTreeListViewViewModel.OnNodeDoubleClicked(RBTreeNode node) in d:\Entwickl\RCC\V1\RCC\Roesberg.TreePropSheet.Core\ViewModels\RBTree\RBTreeListViewViewModel.cs:line 3345 at Roesberg.TreePropSheet.Core.ViewModels.RBTree.RBTreeListViewViewModel.NodeDoubleClickedHandler(RBTreeNode node) in d:\Entwickl\RCC\V1\RCC\Roesberg.TreePropSheet.Core\ViewModels\RBTree\RBTreeListViewViewModel.cs:line 3331 at Roesberg.TreePropSheet.UI.Controls.RBTreeList.TreeListItem.OnMouseDoubleClick(MouseButtonEventArgs e) in d:\Entwickl\RCC\V1\RCC\Roesberg.TreePropSheet.UI\Controls\RBTreeList\TreeListItem.cs:line 74 at System.Windows.Controls.Control.HandleDoubleClick(Object sender, MouseButtonEventArgs e) at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget) at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent) at System.Windows.UIElement.OnMouseDownThunk(Object sender, MouseButtonEventArgs e) at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget) at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) at System.Windows.ContentElement.RaiseTrustedEvent(RoutedEventArgs args) at System.Windows.Input.InputManager.ProcessStagingArea() at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input) at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport) at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel) at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at System.Windows.Interop.HwndSource.InputFilterMessage(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)
As a workaround I had to do 2 things:
1. Create an own control inheriting from XamDataGrid:
public class DataGridNonAutomation : XamDataGrid { protected override AutomationPeer OnCreateAutomationPeer() { return new EmptyAutomationPeer(this); } }
public class EmptyAutomationPeer : FrameworkElementAutomationPeer { public EmptyAutomationPeer(FrameworkElement owner) : base(owner) { } protected override List<AutomationPeer> GetChildrenCore() { return new List<AutomationPeer>(); } }
2. Remove the following FieldSetting: AllowRecordFiltering="True"
Here's the resulting XAML:
<controls:DataGridNonAutomation x:Name="PropertyGrid" DataSource="{Binding DocumentData}" Theme="Office2k7Black" GroupByAreaLocation="AboveDataArea" ScrollingMode="Immediate"> <controls:DataGridNonAutomation.FieldLayouts> <igDP:FieldLayout> <igDP:Field Name="Caption" Visibility="Visible" Width="220" Label="Bezeichnung" Localization.Attributes="Label(Text Readable Modifiable)"/> <igDP:Field Name="Value" Visibility="Visible" Width="*" Label="Wert" Localization.Attributes="Label(Text Readable Modifiable)"/> <igDP:Field Name="Group" Visibility="Visible" Width="*" Label="Gruppe" Localization.Attributes="Label(Text Readable Modifiable)"/> <igDP:FieldLayout.SortedFields> <igDP:FieldSortDescription IsGroupBy="True" Direction="Ascending" FieldName="Group" /> igDP:FieldLayout.SortedFields> </igDP:FieldLayout> </controls:DataGridNonAutomation.FieldLayouts> <controls:DataGridNonAutomation.FieldSettings> <igDP:FieldSettings AllowEdit="False" CellClickAction="SelectRecord" AllowGroupBy="True" CellVisibilityWhenGrouped="Collapsed" /> <controls:DataGridNonAutomation.FieldSettings> <controls:DataGridNonAutomation.FieldLayoutSettings> <igDP:FieldLayoutSettings HighlightAlternateRecords="False" AllowDelete="False" HeaderPlacementInGroupBy="OnTopOnly"/> </controls:DataGridNonAutomation.FieldLayoutSettings></controls:DataGridNonAutomation>
This works but I want the RecordFiltering working and don't want to have to override some or all controls to be able to override OnCreateAutomationPeer().
Maybe the post http://stackoverflow.com/questions/4017786/wpf-recursive-call-to-automation-peer-api-is-not-valid could gives a hint describing a problem with a combobox withing the grid.The record filter uses a XamComboBox...
Please have a look at it and give me a short feedback what to do.Sorry, but I can't give a small example project for reproducing the error. But maybe the stacktrace helps.
Best regardscew3
Hello again,
Could you please verify that you use the latest service release of 12.1 (12.1.20121.2314). If not you can download the Service Releases by logging to our web site and going to Account \Keys & Downloads.
https://es.infragistics.com/my-account/keys-and-downloads/
Looking forward for your reply.
Hi Stefen,
Thanks for your reply. We are using Netadvantage 2012.1 version for wpf.
Regards,
Meenu
Hello Meenu,
Could you please tell me the exact version of NetAdvantage that you use?
We are using TestAdvantage for WPF (for HP QuickTest Professional software) 2012 Vol. 1. While executing the steps with QTP along with Testadvantage add-in , we get above error but while doing manually the same steps in application , we dont get that error.
Hi Juan,
I have just replied to your original post. Here.