I am working on a windows store app using c# and XAML. I want people to be able to change the text size in my "settings" menu all across the application (on several pages). So far I have found a solution, but it only works with the current TextBlock that I have bound to a slider.
I can change the font size of a single textblock in XAML like this: With a simple textblock using a binding on fontsize bound to the slider:
<TextBlock x:Name="TextBox1" HorizontalAlignment="Left" TextWrapping="Wrap" Text="Change my font size." VerticalAlignment="Top" Height="277" Width="430" FontSize="{Binding Value, ElementName=TextSlider}"/>
<Slider x:Name="TextSlider" HorizontalAlignment="Left" Margin="160,113,0,0" VerticalAlignment="Top" Width="100" Value="14" Minimum="1" Maximum="42" />
What I want to do is to bind the font size of all my TextBlock's to a single slider at my settings page. So when you slide the slider, the size of the text changes accordingly to the value of the slider on all pages. Thank you, I would appreciate any tips on how to do this :)
You could define a "DoubleViewModel" (click to see more) - a {StaticResource}
in your App.Resources
dictionary that all FontSize
properties in your app bind to and your slider's Value
TwoWay
-binds to. Then sliding the slider will update all the sizes.