Skip to content
Discussion options

You must be logged in to vote

I‌ had to build a workaround:

  • I reworked the bound view-model value to contain a model that incorporated theme specific data.
  • I added an extension method Themed to that model to set or override that themed data in that model.
  • I changed the view-model to be disposable and added:
      // At the end of the constructor
      Value = /* Value construction code */.Themed(Application.Current!.RequestedTheme);
      Application.Current!.RequestedThemeChanged += OnThemeChanged;
    }
    
    void OnThemeChanged(object? sender, AppThemeChangedEventArgs e)
    => Value = Value.Themed(e.RequestedTheme);
    
    public void Dispose()
    {
      GC.SuppressFinalize(this);
      Application.Current!.RequestedThemeChanged -= OnThemeChanged;
    }

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Ghostbird
Comment options

Answer selected by Ghostbird
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant