如何在多个页面上更改fontsize? [英] How do you change fontsize on multiple pages?

查看:87
本文介绍了如何在多个页面上更改fontsize?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用c#和XAML开发一个Windows应用商店应用。我希望人们能够在整个应用程序的设置菜单中更改文本大小(在几个页面上)。到目前为止,我已经找到了一个解决方案,但它只适用于我已绑定到滑块的当前TextBlock。



我可以更改单个文本块的字体大小在XAML中这样:使用绑定到滑块的fontsize上的绑定的简单文本块:

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" />





我想要做的是将我所有TextBlock的字体大小绑定到我的设置页面上的单个滑块。因此,当您滑动滑块时,文本的大小会相应地更改为所有页面上滑块的值。

谢谢,我将不胜感激任何有关如何执行此操作的提示:)



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 :)

推荐答案

使用 ResourceDictionary

http://blogs.msdn.com/b/wpfsldesigner/ archive / 2010/06/03 / creating-and-consume-resource-dictionaries-in-wpf-and-silverlight.aspx [ ^ ],

http://www.c-sharpcorner.com/uploadfile/raj1979/ resourcedictionary-in-wpf [ ^ ],

http:// wpftutorial .net / MergedDictionaryPerformance.html [ ^ ]。



此CodeProject文章也很有用:在WPF中使用资源字典 [ ^ ]。



-SA
Use ResourceDictionary:
http://blogs.msdn.com/b/wpfsldesigner/archive/2010/06/03/creating-and-consuming-resource-dictionaries-in-wpf-and-silverlight.aspx[^],
http://www.c-sharpcorner.com/uploadfile/raj1979/resourcedictionary-in-wpf[^],
http://wpftutorial.net/MergedDictionaryPerformance.html[^].

This CodeProject article can also be useful: Using a Resource Dictionary in WPF[^].

—SA


这篇关于如何在多个页面上更改fontsize?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆