Home Forums WPF controls Xceed DataGrid for WPF Resource Not Found Exceptions

Viewing 15 posts - 1 through 15 (of 34 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #21900 |

    I am getting System.Windows.ResourceReferenceKeyNotFoundException thrown when I move the focus into some cells of my grid. The ResourceName is the name of the class I am binding to in my ItemsSource

    Any ideas why this is happening?

    Imported from legacy forums. Posted by nmosafi (had 24827 views)

    Xceed Support
    Member
    Post count: 5658

    There is a default CellEditor selector in place (invisible) that will try to select a default cell editor based on the DataType… When no editor is found, an exception is raised but suppressed immediately…

    However, while observing the debug output of an application, you can still see this exception pass (or if you have enabled the “Break on all exceptions” options)…

    If this description does not fit what you see in your application, or if the exception is unhandled, I’d like to have more information.

    Imported from legacy forums. Posted by Marcus [Xceed] (had 930 views)

    User (Old forums)
    Member
    Post count: 23064

    Hmm I do not have that option on.

    However, in my application I am subscribing to the DispatcherUnhandledException. Usually things like binding errors are swallowed, but I am getting exceptions propagated to my exception handler.

    I am also seeing if I double click on a cell in a read only column I get the exception

    [Xceed.Wpf.DataGrid.DataGridException] {“An attempt was made to edit a readonly cell.”} Xceed.Wpf.DataGrid.DataGridException

    Why are these getting propagated?

    Cheers
    Neil

    Imported from legacy forums. Posted by nmosafi (had 682 views)

    User (Old forums)
    Member
    Post count: 23064

    A bit more info on whats going on. The framework ends up with a COMException: No layout currently available.

    From what i can see in the stacktrace, it all comes from the DataGrid.Cell.HideEditTemplate which trigger a TextPropertyChanged on the text box used in the editor, which in turns ends up after two managed / unmanaged transitions to TextStore.GetVisualInfo.

    I’m pretty sure by that time the textbox has already been detached or disposed, and has no visual anymore, hence the exception.

    The full stack trace is reproduced below.

    PresentationFramework.dll!System.Windows.Documents.TextStore.GetVisualInfo(out System.Windows.PresentationSource source, out System.Windows.Interop.IWin32Window win32Window, out System.Windows.Documents.ITextView view) + 0xa3 bytes
    PresentationFramework.dll!System.Windows.Documents.TextStore.MS.Win32.UnsafeNativeMethods.ITextStoreACP.GetTextExt(int viewCookie, int startIndex = 0, int endIndex = 0, out MS.Win32.UnsafeNativeMethods.RECT rect = {MS.Win32.UnsafeNativeMethods.RECT}, out bool clipped) + 0x59 bytes
    [Native to Managed Transition]
    [Managed to Native Transition]
    PresentationFramework.dll!System.Windows.Documents.TextStore.GrantLock() + 0x69 bytes
    PresentationFramework.dll!System.Windows.Documents.TextStore.GrantLockWorker(MS.Win32.UnsafeNativeMethods.LockFlags flags) + 0x33 bytes
    PresentationFramework.dll!System.Windows.Documents.TextStore.RequestLock(MS.Win32.UnsafeNativeMethods.LockFlags flags, out int hrSession) + 0x7f bytes
    [Native to Managed Transition]
    [Managed to Native Transition]
    PresentationFramework.dll!System.Windows.Documents.TextStore.OnSelectionChanged() + 0x1c bytes
    PresentationFramework.dll!System.Windows.Documents.TextSelection.System.Windows.Documents.ITextRange.NotifyChanged(bool disableScroll = false) + 0x1e bytes
    PresentationFramework.dll!System.Windows.Documents.TextRangeBase.EndChange(System.Windows.Documents.ITextRange thisRange = {System.Windows.Documents.TextSelection}, bool disableScroll) + 0xc6 bytes
    PresentationFramework.dll!System.Windows.Documents.TextRange.System.Windows.Documents.ITextRange.EndChange(bool disableScroll) + 0xb bytes
    PresentationFramework.dll!System.Windows.Documents.TextRange.ChangeBlock.System.IDisposable.Dispose() + 0xf bytes
    PresentationFramework.dll!System.Windows.Controls.TextBox.OnTextPropertyChanged(System.Windows.DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e) + 0x336 bytes
    WindowsBase.dll!System.Windows.DependencyObject.OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs e) + 0x51 bytes
    PresentationFramework.dll!System.Windows.FrameworkElement.OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs e) + 0x40 bytes
    PresentationFramework.dll!System.Windows.Controls.TextBox.OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs e) + 0x25 bytes
    WindowsBase.dll!System.Windows.DependencyObject.NotifyPropertyChange(System.Windows.DependencyPropertyChangedEventArgs args) + 0x2b bytes
    WindowsBase.dll!System.Windows.DependencyObject.UpdateEffectiveValue(System.Windows.EntryIndex entryIndex, System.Windows.DependencyProperty dp = {Text}, System.Windows.PropertyMetadata metadata, System.Windows.EffectiveValueEntry oldEntry, ref System.Windows.EffectiveValueEntry newEntry = {System.Windows.EffectiveValueEntry}, bool coerceWithDeferredReference, System.Windows.OperationType operationType) + 0x50b bytes
    WindowsBase.dll!System.Windows.DependencyObject.InvalidateProperty(System.Windows.DependencyProperty dp) + 0xcc bytes
    PresentationFramework.dll!System.Windows.StyleHelper.ClearTemplateChain(System.Collections.Specialized.HybridDictionary[] instanceData, System.Windows.FrameworkElement feContainer = {System.Windows.Controls.ContentPresenter}, System.Windows.FrameworkContentElement fceContainer, System.Collections.Generic.List<System.Windows.DependencyObject> templateChain = Count = 1, System.Windows.FrameworkTemplate oldFrameworkTemplate = {System.Windows.DataTemplate}) + 0x2d6 bytes
    PresentationFramework.dll!System.Windows.StyleHelper.ClearGeneratedSubTree(System.Collections.Specialized.HybridDictionary[] instanceData, System.Windows.FrameworkElement feContainer = {System.Windows.Controls.ContentPresenter}, System.Windows.FrameworkContentElement fceContainer = null, System.Windows.FrameworkTemplate oldFrameworkTemplate) + 0xc4 bytes
    PresentationFramework.dll!System.Windows.StyleHelper.DoTemplateInvalidations(System.Windows.FrameworkElement feContainer, System.Windows.FrameworkTemplate oldFrameworkTemplate) + 0x187 bytes
    PresentationFramework.dll!System.Windows.Controls.ContentPresenter.OnTemplateChanged(System.Windows.DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e) + 0x89 bytes
    WindowsBase.dll!System.Windows.DependencyObject.OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs e) + 0x51 bytes
    PresentationFramework.dll!System.Windows.FrameworkElement.OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs e) + 0x40 bytes
    WindowsBase.dll!System.Windows.DependencyObject.NotifyPropertyChange(System.Windows.DependencyPropertyChangedEventArgs args) + 0x2b bytes
    WindowsBase.dll!System.Windows.DependencyObject.UpdateEffectiveValue(System.Windows.EntryIndex entryIndex, System.Windows.DependencyProperty dp = {Template}, System.Windows.PropertyMetadata metadata, System.Windows.EffectiveValueEntry oldEntry, ref System.Windows.EffectiveValueEntry newEntry = {System.Windows.EffectiveValueEntry}, bool coerceWithDeferredReference, System.Windows.OperationType operationType) + 0x50b bytes
    WindowsBase.dll!System.Windows.DependencyObject.SetValueCommon(System.Windows.DependencyProperty dp, object value, System.Windows.PropertyMetadata metadata, bool coerceWithDeferredReference, System.Windows.OperationType operationType, bool isInternal) + 0x32f bytes
    WindowsBase.dll!System.Windows.DependencyObject.SetValue(System.Windows.DependencyProperty dp, object value) + 0x33 bytes
    PresentationFramework.dll!System.Windows.Controls.ContentPresenter.OnContentTemplateChanged(System.Windows.DataTemplate oldContentTemplate, System.Windows.DataTemplate newContentTemplate) + 0x42 bytes
    PresentationFramework.dll!System.Windows.Controls.ContentPresenter.OnContentTemplateChanged(System.Windows.DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e) + 0x62 bytes
    WindowsBase.dll!System.Windows.DependencyObject.OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs e) + 0x51 bytes
    PresentationFramework.dll!System.Windows.FrameworkElement.OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs e) + 0x40 bytes
    WindowsBase.dll!System.Windows.DependencyObject.NotifyPropertyChange(System.Windows.DependencyPropertyChangedEventArgs args) + 0x2b bytes
    WindowsBase.dll!System.Windows.DependencyObject.UpdateEffectiveValue(System.Windows.EntryIndex entryIndex, System.Windows.DependencyProperty dp = {ContentTemplate}, System.Windows.PropertyMetadata metadata, System.Windows.EffectiveValueEntry oldEntry, ref System.Windows.EffectiveValueEntry newEntry = {System.Windows.EffectiveValueEntry}, bool coerceWithDeferredReference, System.Windows.OperationType operationType) + 0x50b bytes
    WindowsBase.dll!System.Windows.Dependen

    Imported from legacy forums. Posted by Sebastien (had 1172 views)

    User (Old forums)
    Member
    Post count: 23064

    ResourceReferenceKeyNotFoundException: could you post the markup and/or code that you use to initialize the ItemsSource of the DataGrid?

    Edit a readonly cell exception: this bug has been fixed in the latest package, available here:

    http://download3.xceedsoft.com/Packages/3.0.7113.09060/XceedComponents.exe

    See this thread for reference: http://forums.xceed.com/forums/ShowPost.aspx?PostID=5549

    Imported from legacy forums. Posted by Pascal (had 426 views)

    User (Old forums)
    Member
    Post count: 23064

    SerialSeb: Is your post related to the current thread? If so, could you please provide more context? If not, could you please start a new thread?

    Thanks! 🙂

    Imported from legacy forums. Posted by Pascal (had 551 views)

    User (Old forums)
    Member
    Post count: 23064

    Let me get the latest version and retest, I’ll let you know if I still have problems

    Cheers
    Neil

    Imported from legacy forums. Posted by nmosafi (had 593 views)

    User (Old forums)
    Member
    Post count: 23064

    FYI Seb and Myself are both working on the same system!

    Imported from legacy forums. Posted by nmosafi (had 857 views)

    User (Old forums)
    Member
    Post count: 23064

    <i>Seb and Myself are both working on the same system</i>

    Aahhh… I had not realized that… Sorry about that! 🙂

    Imported from legacy forums. Posted by Pascal (had 399 views)

    User (Old forums)
    Member
    Post count: 23064

    Right, I have updated and am still getting the ResourceKeyNotFoundException (although the read only one has gone away).

    Here is the exact markup for the grid.

    <xcdg:DataGridControl ItemsSource=”{Binding Path=InboundFlights}” AutoCreateColumns=”False” Grid.IsSharedSizeScope=”True”>
    <xcdg:DataGridControl.Columns>
    <xcdg:Column FieldName=”Code” Title=”Code” DisplayMemberBinding=”{Binding Path=Flight.FlightCode}” ReadOnly=”True” Width=”50″ />
    <xcdg:Column FieldName=”Description” Title=”Description” DisplayMemberBinding=”{Binding Path=Flight}” CellContentTemplate=”{StaticResource FlightDescriptionTemplate}” ReadOnly=”True” Width=”220″ />
    <xcdg:Column FieldName=”Days” Title=”Days” DisplayMemberBinding=”{Binding Path=Flight.DaysOfOperation}” ReadOnly=”True” />
    <xcdg:Column FieldName=”OperationalPeriods” Title=”Operational Periods” DisplayMemberBinding=”{Binding Path=Flight}” CellContentTemplate=”{StaticResource PeriodsOfOperationTemplate}” ReadOnly=”True” />
    <xcdg:Column FieldName=”SingleYield” Title=”Single Yield” DisplayMemberBinding=”{Binding Path=Single, Converter={StaticResource FormattingConverter}, ConverterParameter=[0:£0.00]}” Width=”80″>
    <xcdg:Column.CellEditor>
    <xcdg:CellEditor>
    <xcdg:CellEditor.EditTemplate>
    <DataTemplate>
    <xcd:AutoSelectTextBox Text=”{Binding RelativeSource={RelativeSource AncestorType={x:Type xcdg:DataCell}}, Path=DataContext.Single, Converter={StaticResource FormattingConverter}, ConverterParameter=[0:0.00]}” />
    </DataTemplate>
    </xcdg:CellEditor.EditTemplate>
    </xcdg:CellEditor>
    </xcdg:Column.CellEditor>
    </xcdg:Column>
    <xcdg:Column FieldName=”ReturnYield” Title=”Return Yield” DisplayMemberBinding=”{Binding Path=Return, Converter={StaticResource FormattingConverter}, ConverterParameter=[0:£0.00]}” Width=”80″>
    <xcdg:Column.CellEditor>
    <xcdg:CellEditor>
    <xcdg:CellEditor.EditTemplate>
    <DataTemplate>
    <xcd:AutoSelectTextBox Text=”{Binding RelativeSource={RelativeSource AncestorType={x:Type xcdg:DataCell}}, Path=DataContext.Return, Converter={StaticResource FormattingConverter}, ConverterParameter=[0:0.00]}” />
    </DataTemplate>
    </xcdg:CellEditor.EditTemplate>
    </xcdg:CellEditor>
    </xcdg:Column.CellEditor>
    </xcdg:Column>
    </xcdg:DataGridControl.Columns>

    <xcdg:DataGridControl.View>
    <xcdg:TableView ShowRowSelectorPane=”False”>
    <xcdg:TableView.FixedHeaders>
    <xcdg:ClearHeadersFooters />
    <DataTemplate>
    <xcdg:ColumnManagerRow Width=”{Binding RelativeSource={RelativeSource AncestorType={x:Type ScrollContentPresenter}}, Path=ActualWidth}” />
    </DataTemplate>
    </xcdg:TableView.FixedHeaders>
    </xcdg:TableView>
    </xcdg:DataGridControl.View>

    </xcdg:DataGridControl>

    Imported from legacy forums. Posted by nmosafi (had 575 views)

    User (Old forums)
    Member
    Post count: 23064

    I have tried removing the DispatcherUnhandledException and everything is fine. I still get “A first chance exception of type ‘System.Windows.ResourceReferenceKeyNotFoundException’ occurred in PresentationFramework.dll” as I navigate around the DataGrid using the keyboard, but I will handle that in my exception handler, for now.

    I am getting another issue and don’t know whether to post to another thread or not. If I edit the content of a cell and then move the focus to another cell in the same row, the content does not get updated properly. It’s only when I move focus to the next row that the cell gets updated.

    Does that make sense?

    Imported from legacy forums. Posted by nmosafi (had 366 views)

    User (Old forums)
    Member
    Post count: 23064

    Could you please try to remove your custom CellEditors from all the columns that have one and tell me if you still get the first chance exception and/or the problem where the cell content is only updated when you move to another row?

    Thanks!

    Imported from legacy forums. Posted by Pascal (had 413 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi Pascal

    I have updated the code to not use any custom CellEditor and I still see both issues

    Regards
    Neil Mosafi

    Imported from legacy forums. Posted by nmosafi (had 514 views)

    User (Old forums)
    Member
    Post count: 23064

    Interesting… What is the type of you data source (InboundFlights)?

    Imported from legacy forums. Posted by Pascal (had 296 views)

    User (Old forums)
    Member
    Post count: 23064

    It’s actually a ListCollectionView bound to a collection of YieldFactDataModel.

    The Single and Return properties are of type decimal?

    Note that if I set a breakpoint in the Converter’s ConvertBack function, it is not called until I click on another row… does that help?

    Thanks
    Neil

    Imported from legacy forums. Posted by nmosafi (had 431 views)

Viewing 15 posts - 1 through 15 (of 34 total)
  • You must be logged in to reply to this topic.