Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

How can i change the color of a button from another class?

$
0
0

Hi again! Im trying to change the color of Apply button when something happens, but i only seem to be able to change the color if i put it inside the button_OnClicked event. I need to change the color from another class, so i tried using an interface but that didnt work either. Help?

This works:

    private async void Button_OnClicked(object sender, EventArgs e)
        {
        ApplyButton.BackgroundColor = Color.FromRgba(52, 152, 219, 255);
        }

This does not work:

        public void FlagApplyChanges()
        {
            ApplyButton.BackgroundColor = Color.FromRgba(52, 152, 219, 255);
        }

Other class:

      var manager = DependencyService.Get<ISettingsPage>();
      Device.BeginInvokeOnMainThread(() => manager.FlagApplyChanges());

Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>