Hello @mrizoiwe98 ,
Welcome to our Microsoft Q&A platform!
I want to have a "safety mode" switch in my app that when enabled I want to use vague strings instead of explicit ones.
First, please add the vague strings to the Resx files. For the 'safety mode', you could create another application template. Set values for the new application template's pages to display the vague strings. When switching to the 'safety mode', naivgate to the safety mode application template via setting App.Current.MainPage
.
You could also try using ControlTemplate
in the pages. Change the control template dynamically when you enable the safe mode.
For example, create two different templates. Display the vague strings in the 'vague page'.
<ContentPage ...
x:Class="TestApplication_5.Page1"
xmlns:resources="clr-namespace:LocalizationDemo.Resx">
<Label Text="{x:Static resources:AppResources.NotesLabel}" />
<Entry Placeholder="{x:Static resources:AppResources.NotesPlaceholder}" />
<Button Text="{x:Static resources:AppResources.AddButton}" />
</ContentPage>
<ContentPage ...
x:Class="TestApplication_5.vague_Page1"
xmlns:resources="clr-namespace:LocalizationDemo.Resx">
<Label Text="{x:Static resources:AppResources.vague_NotesLabel}" />
<Entry Placeholder="{x:Static resources:AppResources.vague_NotesPlaceholder}" />
<Button Text="{x:Static resources:AppResources.vague_AddButton}" />
</ContentPage>
Call App.Current.MainPage
command to display the new application when you switch to the safe mode.
App.Current.MainPage = new VagueMainPage();
ControlTemplate part:
<ContentPage.Resources>
<ControlTemplate x:Key="normal_template">
<Label Text="{x:Static resources:AppResources.NotesLabel}" />
</ControlTemplate>
<ControlTemplate x:Key="vague_template">
<Label Text="{x:Static resources:AppResources.vague_NotesLabel}" />
</ControlTemplate>
</ContentPage.Resources>
<ContentPage.Content>
<!--you could change the contrltemplate via triggers, you may need to create a custom bool property for the page and set binding for it-->
<ContentView ControlTemplate="{DynamicResource normal_template}">
</ContentView>
</ContentPage.Content>
Best Regards,
Jarvan Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.