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:
- Style should be modified, e.g. one of existing setter values needs to change.
- 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:
- Open attached solution in VS.
- Build and run.
- Click on "Change Setter for BackgroundColor" button.
Note: existing labels did not change their color.
- Click on "Add more labels with style" button.
Note: new labels have different color.
XamarinApp1.zip
Consider following XAML
Consider user changing Value="LightGreen" to "Red". For Hot Reload to work correctly two things should happen:
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:
To better understand the issue try following:
Note: existing labels did not change their color.
Note: new labels have different color.
XamarinApp1.zip