Skip to content

[Enhancement] Hot Reload: refresh styled elements after modifying styles #618

Description

@etvorun

Consider following XAML

    <Style x:Key="LabelBase" TargetType="Label">
      <Setter Property="BackgroundColor" Value="LightGreen"/>
    </Style>

Consider user changing Value="LightGreen" to "Red". For Hot Reload to work correctly two things should happen:

  1. Style should be modified, e.g. one of existing setter values needs to change.
  2. All elements consuming such style - directly of via Style.BasedOn inheritance - need to be refreshed.

We need API for 2). That is after VS Hot Reload modifies styles it needs help refreshing all affected elements.
The proposed API can be like this:

namespace Xamarin.Forms.HotReload
{
  class HotReloadHelper
  {
      public void RefreshStyledElements (Style style) {};
  }
}

To better understand the issue try following:

  1. Open attached solution in VS.
  2. Build and run.
  3. Click on "Change Setter for BackgroundColor" button.
    Note: existing labels did not change their color.
  4. Click on "Add more labels with style" button.
    Note: new labels have different color.

XamarinApp1.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions