ControlTemplate binding not refreshing when property changes

thedeethedee USMember ✭✭

I am having an issue binding to a label. On initial load of the page the label gets set correctly but if I change the binding property the label does not change.

In my ControlTemplate that is defined in the App.xaml I have a label definded like:

<StackLayout x:Name="bottomLayout" Orientation="Vertical" VerticalOptions="EndAndExpand" BackgroundColor="White"  Grid.Row="2"
                                 Padding="0" Spacing="0" Margin="0">
                        <Label x:Name="lblConnectionStatus" TextColor="Black" FontSize="Small" Text="{TemplateBinding Parent.ConnectionStatus, Mode=TwoWay}"
                               VerticalOptions="CenterAndExpand"`` 
                               HorizontalOptions="CenterAndExpand" />
                    </StackLayout>

Then I have my property defined like this on the page:
private string _ConnectionStatus;
public string ConnectionStatus { get { return _ConnectionStatus; } set { _ConnectionStatus = value; OnPropertyChanged(); } }

For whatever reason the label that is defined in the template won't change if the property changes. For testing I added another label directly in the page itself and did binding to this same property and that will change like it is suppose to.

Answers

  • mshwfmshwf EGMember ✭✭✭

    Try binding to Parent.BindingContext.ConnectionStatus

Sign In or Register to comment.