sthewissen / Xamarin.Forms.DebugRainbows

The package you didn't even know you needed!
MIT License
415 stars 33 forks source link

Option to activate debug mode in all pages #9

Closed mateuswolkmer closed 5 years ago

mateuswolkmer commented 5 years ago

Have you ever thought about the possibility to enable the Debug Mode in the whole app, setting random colors for every view in every page without the need of adding DebugRainbow.IsDebug="true in the individual pages?

That could be a option you can enable in App.xml.cs, by statically calling some method or variable of DebugRainbow to set the debug in all pages, and it would run whenever a new page is open. Is that possible?

If you could give me directions I may try and create a pull request over the next days. ;)

sthewissen commented 5 years ago

Sorry for not getting back to you earlier! Since it's an attached property one can set on ContentPage and the initialization of content pages might differ based on the MVVM framework you use this could get tricky. Looking at a way to get something like the following to work:

<Style TargetType="ContentPage">
    <Setter Property="debug:DebugRainbow.IsDebug" Value="true" />
</Style>

or...

<Style x:Key="debugPage" TargetType="ContentPage">
    <Setter Property="debug:DebugRainbow.IsDebug" Value="true" />
</Style>
<Style TargetType="ContentPage">
    <Setter Property="Style" Value="{StaticResource debugPage}" />
</Style>
sthewissen commented 5 years ago

This should work:

<Style ApplyToDerivedTypes="True" TargetType="ContentPage">
   <Setter Property="debug:DebugRainbow.IsDebug" Value="false" />
</Style>