So I am working through my first WPF project and I am liking what I see so far. There was more of learning curve than what I anticipated, but nevertheless WPF is pretty cool. However, I am struggling a little bit with the data binding concepts. One specific question I have is how do I make my data binding declarations refactor safe? Consider this example.
public class MyDataObject
{
public string FooProperty { get; set; }
}
void Bind()
{
var gridView = myListView.View as GridView;
gridView.Columns.Clear();
gridView.Columns.Add(
new GridViewColumn()
{
Header = "FooHeader",
DisplayMember = new Binding("FooProperty")
}
);
List<MyDataObject> source = GetData();
myListView.ItemsSource = source;
}
So what if I rename the FooProperty on my data object to something else? The data binding will be invalid and I will not get a compile error since the binding was declared via text only. Is there a way to make the binding a little more refactor safe?