Quick Links

Does anyone get any information when a Binding is wrong (in Visual Studio)?

When a binding is bad in Xamarin Forms (Android or UWP) I don't get any information, it just raises an Exception at the highest level.
Am I supposed to get any debug information? In the current case I know where it is bad because it is the latest change I made but I'm not very comfortable with the feeling that a problem might arise in the future and I will have no idea at all where it is coming from.
I am using Visual Studio 2017.

Answers

@AnthonyWaters.7746 - I switch to debugging on Android when I want to check bindings, as I then get messages such as the following in the Output window of Visual Studio 2017 (and 2015):

Binding: 'Missing' property not found on 'ViewsUsingXamarinForms.FramedEntry', target property: 'ViewsUsingXamarinForms.Entry.Text'

For debugging bindings, it can be useful to add a dummy value converter to bindings, as you can then apply breakpoints in Convert and ConvertBack to see what is happening in the case where properties are found:

@JohnHardman said:@AnthonyWaters.7746 - I switch to debugging on Android when I want to check bindings, as I then get messages such as the following in the Output window of Visual Studio 2017 (and 2015):

Binding: 'Missing' property not found on 'ViewsUsingXamarinForms.FramedEntry', target property: 'ViewsUsingXamarinForms.Entry.Text'

For debugging bindings, it can be useful to add a dummy value converter to bindings, as you can then apply breakpoints in Convert and ConvertBack to see what is happening in the case where properties are found:

I don't think I ever see a Debug message such as that. Certainly not in the latest case I was struggling with. I have fixed that particular problem but I wanted to improve the debugging for the future. In my particular case the Binding source was wrong, and I just get an exception, with no useful information. I also don't get a chance to use the converter as it can never get the value to convert.

I have just done a small test to confirm I don't get any debug messages about failed bindings.
To repeat the test:
1) Create a new Xamarin Forms project using PCL
2) Add the following code in MainPage.xaml but don't add anything else

<ListView ItemsSource="{Binding ListItems}">
</ListView>

3) Run the app in Android or UWP. Obviously the Binding fails because we haven't specified the DataContext or the ListItems property. However, I don't get any Debug messages about Binding. It just doesn't work.

@Zoli - Do you get those binding messages when building for targets other than Android? TBH - I cannot remember if I get them for iOS, but I definitely do not for UWP even though I do for Android. I wonder if there's some configuration setting somewhere that enables/disables those messages?