question

MatteoPozzato-2066 avatar image
0 Votes"
MatteoPozzato-2066 asked GJSchoneveld-6322 commented

DynamicResource not updated

Hi,

in our application we have some global x:Boolean DynamicResource that we use to show\hide some buttons along all the application.

We have updated from XF 4.8.0.1560 to 5.0.0.2083 and that DynamicResource doesn't update the UI anymore.
The value changes correctly but the UI value not changes.

This happens only on iOS devices.

The issue is present from the XF version 5.0.0.1931.
Up to version 5.0.0.1905 works fine.

I'm using the same verision of Xamarin.Essentials.

Steps to Reproduce


  1. add a x:Boolean resource to the resourceDictionary in App.xaml
    ex. <x:Boolean x:Key="MostraMenuDettaglioWo">False</x:Boolean>

  2. add a Button with a command that get and change the resource
    ex:
    bool actual = (bool)Application.Current.Resources["MostraMenuDettaglioWo"]; Device.BeginInvokeOnMainThread(() => { Application.Current.Resources["MostraMenuDettaglioWo"] = !actual; });

  3. bind the resource to something in the XAML page
    ex to the text button:
    <Button BackgroundColor="Red" Command="{Binding TestCommand}" Text="{DynamicResource MostraMenuDettaglioWo}" />


Expected Behavior

The value should be chage and also the UI value.

Actual Behavior

The value changes but not the UI value

Basic Information


  • Version with issue: 5.0.0.2083

  • Last known good version: 5.0.0.1905

  • Platform Target Frameworks:

  • iOS: tested on emulator iPhone with iOS 14.5 and on physical iPhone with iOS 14.6

  • Android: tested on Galaxy S10 with Android 11


Download videos


dotnet-xamarin
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

We have the same problem in our app with XF 5.0.0.2012. Like MatteoPozzato-2066 on iOS only. Reverting back to 5.0.0.1905 fixed it.

0 Votes 0 ·

1 Answer

JarvanZhang-MSFT avatar image
1 Vote"
JarvanZhang-MSFT answered JarvanZhang-MSFT edited

Hello @MatteoPozzato-2066 ,​

Welcome to our Microsoft Q&A platform!

I created a basic demo to test the function with Xamarin.Forms 5.0.0.2083, it works as expected. This is the relevant code, please point it out if there is any difference.

<!--App.xaml-->l
<x:Boolean x:Key="test">False</x:Boolean>

<!--page.xaml-->
<StackLayout>
    <Button Text="Button" Clicked="Button_Clicked"/>
    <Button Text="{DynamicResource test}"/>
</StackLayout>

Page.xaml.cs

public partial class MainPage : ContentPage
{
    public MainPage()
    {
        InitializeComponent();
    }

    private void Button_Clicked(object sender, EventArgs e)
    {
        var test = (bool)Application.Current.Resources["test"];
        Application.Current.Resources["test"] = !test;
    }
}

I tried to use the model class command to check the function, and also tested it in the navigation, both work fine.

Best Regards,

Jarvan Zhang


If the response is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi and thank you for the reply.
The code is like mine, so I think that in my application there is something that doesn't make this works, but this issue is appeared when I have update to that version of XF :(

0 Votes 0 ·

but this issue is appeared when I have update to that version of XF

Please make sure you've updated the nuget on both the shared project and each platform project. Try to clean the bin and obj folder, then open the vs to rebuild the project.

1 Vote 1 ·