XAML:
<navigation:Page ... Title="{Binding Name}">
C#
public TablePage()
{
this.DataContext = new Table()
{
Name = "Finding Table"
};
InitializeComponent();
}
Getting a ag_e_parser_bad_property_value error in InitializeComponent at the point where the title binding is happening. I’ve tried adding static text which works fine. If I use binding anywhere else eg:
<TextBlock Text="{Binding Name}"/>
This doesn’t work either.
I’m guessing it’s complaining because the DataContext object isn’t set but if I put in a break point before the InitializeComponent I can confirm it is populated and the Name property is set.
Any ideas?
You can only use data binding on properties that are supported by
DependencyProperty. If you take a look at the docs forTextBlockfor example you will find that theTextproperty has a matchingTextPropertypublic static field of typeDependencyProperty.If you look at the docs for
Pageyou will find that there is noTitlePropertydefined, theTitleproperty is therefore not a dependency property.Edit
There is no way to “override” this however you could create an attached property:-
Now your page xaml might look a bit like:-