Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect broken bindings in XAML already at compile time

It is a simple and frequent, I think, scenario - you bind in XAML a dependency property to property in the viewmodel and later rename the property in viewmodel and forget to rename it in XAML. So is the binding broken.

Is there a way to detect such a broken bindings already at compile time?

like image 724
Rekshino Avatar asked Apr 04 '17 13:04

Rekshino


1 Answers

you could add the VM-class to your Binding line this:

<DataGrid ItemsSource="{Binding Path=(viewModels:MyViewModel.MyItemsSource)}" />

with:

namespace ViewModels{
    public class MyViewModel{
        public ICollectionView MyItemsSource {get; set;}
    }
}

This shows you BindingErrors at DesignTime

like image 55
WPFGermany Avatar answered Oct 17 '22 09:10

WPFGermany