I am currently developing universal app and I need to handle textbox font size for mobile and desktop separately. I found some approaches but none of them can't handle the problem: Using VisualStateManager with StateTrigger as example:
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="ChangeFontSize">
<VisualState x:Name="Desktop">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="500"/>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="textBox.FontSize" Value="18" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Mobile">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="0"/>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="textBox.FontSize" Value="22" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
does not fit because StateTrigger fires only when screen is resizing. Redefine xaml style:
<x:Double x:Key="MyFontSize">22</x:Double>
\\\\\\
........
\\\\\\
Application.Current.Resources["MyFontsSettings"] = 18;
does not have any effect to the "MyFontSize", it still has value '22'.
Is there any proper way to do this correctly, without setting it on every page and control? I want set it once in styles and use everywhere. Any suggestions are welcome.