This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
When I run a DataGrid with Hierarchical data, I get the following binding exceptions in my output window.
Even though this is just a trace, I think it is slowing down the binding in the grid considerably. How can I fix this? Should I create a property "IsSelected" in my underlying data structure? Here is a screenshot, in case that helps: EDIT: This happens when the node does not have children, and therefore no ToggleButton ! |
|
|
Hello Thanks for pointing this out! There was a bug in the Alloy theme causing this. This has been resolved which you can update through the next nightly build. Jason Fauchelle |
|
|
Solved. Thanks. |
|
|
Also these.... Are they from your grid?
|
|
|
Yes these are also from the grid but they can be safely ignored. Jason Fauchelle |
|
|
Hi Jason, I happened to run across this old thread while googling the exact same data error in the debug output: System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=ColumnDropRequestPosition; DataItem=null; target element is 'TranslateTransform' (HashCode=47680691); target property is 'X' (type 'Double') Now I do believe you when you say we can safely ignore such messages. However, I still find such messages irritating because 1) I just spent time googling it. 2) There is no simple way to tell where the message is originating, so it is not so easy to tell whether it is harmless (this is Microsoft's fault). 3) The next programmer here that sees this output will probably also wonder if it can safely be ignored. 4) It will pollute my debug output in perpetuity. I know I can arrange to not output data errors like this, but then I would probably miss errors that are important. So if there is any way to get rid of this "error" I would greatly appreciate it. Thanks Peter |
|
|
Hello Peter I have not been able to reproduce these particular binding errors recently. If you could give any information related to how the DataGrid is set up to cause this error, that would help a lot. Or/and, let me know which theme you are using, and I'll attempt a fix by changing the point in code where the binding is. -Jason Fauchelle |
|
|
Hi Jason, Thanks for looking into this. If you believe that this problem has been fixed, then maybe the reason I am seeing these errors is that while I am using a very recent version of the DataGrid, I am using a modified version of the control template that is adapted from an older version of the default DataGrid template. The main reason I changed the control template was to support multi-line column headers (see picture below), but perhaps this is keeping this old problem around. If you happened to remember what change fixed this problem it might be helpful to me to eliminate the problem from my template. However, I know that once I start using my own template I am mostly "on my own". Thanks Peter |
|
|
Hello Peter Your multi-line column headers look very impressive. Unfortunately I can not remember anything that I did that could have caused this issue to be resolved. I'm not sure if it was ever resolved, it may just be that it does not work in certain DataGrid usages. If you have made a custom DataGridHeaderRowPresenter style, here is what you could try: Search your code for "ColumnDropRequestPosition". You should see that this is being bound to by a TranslateTransform object. As this is not actually part of the visual tree, this may explain why the binding errors can sometimes occur - probably an issue with the order that bindings are being resolved. Now, Remove the Grid.RenderTransform tag, and set the RenderTransform property directly on the Grid tag. You'll want this to be a binding to the ColumnDropRequestPosition property, and use a simple converter that you will need to implement which takes a double value, and returns a TranslateTransform with X set to that double value. Let me know if you need help making this change. -Jason Fauchelle |
|
|
Hi Jason, Actually, I have not created a custom DataGridHeaderRowPresenter style. I use a subclass of DataGridHeaderRowPresenter that provides me access to the realized header collection (questionable programming, I know), but I didn't modify the default style. I did a little further research on these messages and ran across the following post: http://stackoverflow.com/questions/3181890/binding-in-wpf-style-causes-inexplicable-cannot-find-governing-frameworkelement. It seems clear that this is a Microsoft issue, and not your problem. However, there is the following interesting tidbit in one of the comments: "I also cannot explain why the error message happens, but I have found out that adding an x:Name property to the transform is a way to get rid of the error message". I set x:Name="dummy" on the two TranslateTransforms in DataGrid.Generic.xaml, and confirmed that the messages stopped appearing. Strange! This make me happy, because I find spurious messages to be annoying. Thanks Peter |
|
|
Hello Peter Thanks for finding a solution and letting us know! It is certainly odd, but if it works, it works. I've updated all our data grid themes to name the transforms so that you don't need to maintain this change in your local copy of the themes. This will be available in the next nightly build. -Jason Fauchelle |
|