Home Forums WPF controls Xceed DataGrid for WPF DataContext for DataCell set (too) late?

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

    Hi,

    Within a CellContentTemplate I’m using Bindings to attached properties.
    These properties cause errors in my Trace:

    System.Windows.Data Error: 12 : Cannot get ‘(prod:PageField.HasInfo)’ value (type ‘Boolean’) from ” (type ‘String’). BindingExpression:Path=(0); DataItem=’String’ (HashCode=757602046); target element is ‘TextBlock’ (Name=”); target property is ‘Text’ (type ‘String’) InvalidCastException:’System.InvalidCastException: Unable to cast object of type ‘System.String’ to type ‘System.Windows.DependencyObject’.
    at MS.Internal.Data.PropertyPathWorker.GetValue(Object item, Int32 level)
    at MS.Internal.Data.PropertyPathWorker.RawValue(Int32 k)’

    however, once the grid displays it all works fine.

    Could it be that the DataContext for the cell is set (too) late so that the Binding is first evaluated against a false DataContext being an empty String with HashCode 757602046??
    This HashCode is the same for every row!!
    The error being an exception (handling of which is slow) might cause a huge performance penalty when the grid contains many rows and/or attached property bindings.

    Imported from legacy forums. Posted by Nelis (had 552 views)

    Xceed Support
    Member
    Post count: 5658

    It would appear like you are right… if you do a string.Empty.GetHashCode(), you will obtain the same value…

    However, we have not seen this case before (where the DataContext of a CellContentTemplate defaults to string.Empty before actual content kicks in)…

    Maybe you could try to see if setting a FallbackValue on the binding “cancels” the error (and hopefully, restores any performance degradation obtained because of the multiple binding errors).

    Let me know what happens with this issue.

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

    User (Old forums)
    Member
    Post count: 23064

    Thnx for the quick reply

    Using a FallbackValue does not make the exception trace disappear.

    With respect to the performance: I did not investigate what exactly causes the problem but it usually takes several seconds for my grid (on a TabControl) to appear. Whether it is my code, the number of rows, the number of WPF controls or your control I do not know (yet).
    Nevertheless this issue could probably help you improve your grid further.

    Imported from legacy forums. Posted by Nelis (had 415 views)

    Xceed Support
    Member
    Post count: 5658

    I’d definitely like to see a simple repro application for this issue…

    Would it be possible to send me your code or a stripped down version of your code that reproduces the issue?

    If you can, you can send it to support@xceedsoft.com, but make sure to reference this forum post ( URL is fine )

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

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