Xamarin.Forms icon indicating copy to clipboard operation
Xamarin.Forms copied to clipboard

[Bug] Shell Tab Title property don't change value respect the binding declaration

Open ncarandini opened this issue 5 years ago • 3 comments

Description

Can't bind the Shell Tab Tittle property to a ViewModel property.

Steps to Reproduce

I've made a GitHub project that repro the issue: ncarandini/XFShellBug

  1. Bind Title and Icon to VM properties:
<Shell.BindingContext>
    <vm:AppShellViewModel/>
</Shell.BindingContext>
...
<Tab Title="{Binding LogInOutTitle}" Icon="{Binding LogInOutIconName}">
    <ShellContent ContentTemplate="{DataTemplate views:LoginPage}" />
</Tab>
  1. Somehow change the values of LogInOutTitle and LogInOutIconName at runtime:
public string LogInOutTitle => !((App)Application.Current).IsUserLogged ? "Login" : "Logout";
public string LogInOutIconName => !((App)Application.Current).IsUserLogged ? "tab_login.png" : "tab_logout.png";

Expected Behavior

The Title and Icon of the Shell Tab element shall change following the XAML binding declaration.

Actual Behavior

The Icon changes accordingly but the Title don't.

Basic Information

  • Xamarin.Forms: 4.6.0.800

Screenshots

image

Reproduction Link

I've made a GitHub project that repro the issue: ncarandini/XFShellBug

ncarandini avatar May 28 '20 06:05 ncarandini

+1 It is impossible for us to apply our InApp Translation to the Shell because the Binding is defined as OneTime.

denzerd avatar Jul 28 '20 13:07 denzerd

For the code in the repro you can set the Binding Mode to OneWay or TwoWay manually and then it works, i.e.:

<Tab Title="{Binding LogInOutTitle, Mode=OneWay}" Icon="{Binding LogInOutIconName}">
    <ShellContent ContentTemplate="{DataTemplate views:LoginPage}" />
</Tab>

jfversluis avatar Aug 13 '21 13:08 jfversluis

@jfversluis , If we bind the DataTemplate through binding in ContentTemplate and change the template at runtime, it is not updated. I looked into the source code and the PropertyChanged is not invoked for ContentTemplate bindable property and so it won't get update. Is there any way to update the new template at runtime?

Thanks

dinesh4official avatar Oct 25 '23 09:10 dinesh4official