0

I am wiring up a binding in code (NOT in XAML).

Is there any way of determining whether the binding path is valid? The obvious candidate is IsDataBound property, but this is always true even if the path is wrong.

Currently I am fudging it by supplying a fallback value and testing for that, but is there a better way?

3 Answers 3

1

If you don't mind upgrading your project to Silverlight 5, check out the Silverlight 5 RC. With SL5 debugging databinding has become a breeze since it enables you to set breakpoints inside your XAML code where the binding happens.

Check out this article for a full overview how this works.

Sign up to request clarification or add additional context in comments.

1 Comment

I've marked this as answer, as although the article didn't answer my question directly, it gave me enough clues to find the answer, which is: if (GetBindingExpression(MyDependencyProperty).Status != BindingStatus.Active) MessageBox.Show("BINDING FAILED");
1

The Output-window of Visual Studio is a good place to start, for a more indepth guide on debugging bindings see this MSDN article.

2 Comments

Sorry, I mean at runtime so I can react to it, not in a debug scenario.
@GazTheDestroyer: One normally does debugging at runtime (read the article), or what exactly do you mean by runtime?
1

I guess you could use a ValueConverter, which you can add pretty easily in code to your binding and will let you evaluate what is going on between the source and target properties.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.