I have a user control defined as follows:
<UserControl ...
......
x:name="StartPage">
<ToggleButton
x:Name="FullScreenToggle"
Content="{Binding ElementName=StartPage,Path=FullScreenState,Mode=OneWay}" />
</UserControl>
in the code behind:
public String FullScreenState
{
get;
set;
}
However for some reason the ToggleButton’s Content property doesn’t pick up the property.
Any ideas?
Your binding is perfectly valid, but you need to use an updatable property or the view will not be notified of the property changing.
Basically it needs to call PropertyChanged with the details of the changed property:
This means your control has to implement INotifyPropertyChanged:
and provide the event handler:
*As mentioned by tam, you can also use a dependency property if you want to extend your control for use in other controls. Horses for courses 🙂