c# - How to hunt down WPF binding errors? -
We have a very large project that has many duplicated WPF binding errors in the Visual Studio debug output log, for example:
System.Windows.Data Error: 5: Value produced by the binding expression is not valid for the target asset. Value = 'nan' binding expression: path = width; DataItem = 'Content Viewer' (name = ''); Target element 'content display' (name = ''); Target Property 'MaxWidth' (type 'double')
Lines are printed during some actions. However, this is a very heavy operation, in which tens of WPF classes are included.
Is there a quick way to find the exact source of the binding error? Some devices that can help
The error you see is because MaxWidth
For the second control the width
is being compelled MaxWidth
must have a certain numeric value, but width There may be many non-fixed values. In this case, the source control width is
NaN
- which is an invalid value for MaxWide
. This is causing the error.
So, I'm looking for a control binding where you're setting MaxWidth = "{binding width, elementname = some element}",
, or similar.
On an estimate, it has been put in compulsive place because there is control in a layout panel like a StackPanel
which does not limit the size of its children, and any To tackle clipping issues, try to bind MaxWidth
is a better solution to switch to a panel control which limits its content size.
The operation is being done, there is no way to do this with error in this case, except that it is invalidating your layout.
Comments
Post a Comment