加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

Windows Phone – 以编程方式获取手机口音刷C#

发布时间:2020-12-13 20:17:21 所属栏目:Windows 来源:网络整理
导读:我在xaml中有文本框 TextBlock Style="{StaticResource PhoneTextExtraLargeStyle}" FontSize="{StaticResource PhoneFontSizeLarge}" FontFamily="{StaticResource PhoneFontFamilySemiLight}" Margin="12,10,12,0" / 如何从Windows Phone 7 / 7.5 / 8的系
我在xaml中有文本框
<TextBlock Style="{StaticResource PhoneTextExtraLargeStyle}" FontSize="{StaticResource PhoneFontSizeLarge}" FontFamily="{StaticResource PhoneFontFamilySemiLight}" Margin="12,10,12,0" />

如何从Windows Phone 7 / 7.5 / 8的系统资源中以编程方式(c#)获取phoneaccentbrush的价值,以便我可以将前景色设置为与WP设置中选择的重音相匹配.

首先,您需要在C#类的构造函数之前创建currentAccentColorHex:
public partial class MainPage : PhoneApplicationPage
{
    Color currentAccentColorHex = (Color)Application.Current.Resources["PhoneAccentColor"];

    // Constructor
    public MainPage()
    {          
        //...

然后在需要为控件设置颜色的地方使用它:控件MyControl的Background属性示例:

SolidColorBrush backColor = new SolidColorBrush(currentAccentColorHex);
MyControl.Background = backColor;

希望这个帮助

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读