博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
How to use String Resources
阅读量:4135 次
发布时间:2019-05-25

本文共 992 字,大约阅读时间需要 3 分钟。

In this Tip I will be showing you how to place hard coded strings into a resource area. This is a common best practice for software development that makes it much easier to manage the strings in your application.

To start, open up your App.xaml file and add a reference to the MSCORLIB library as seen highlighted here.

<Application xmlns=

xmlns:x= 
xmlns:clr
="clr-namespace:System;assembly=mscorlib"
x:Class="TestApp.App">

One place you can add all your strings is under the Application.Resources section in your App.xaml. To illustrate this, I have added one string resource that can be referenced through the key “MyName”.

<Application.Resources>

    <clr:String x:Key="MyName">Mike Snow</clr:String>
</Application.Resources>

Finally, open up Page.xaml and add a TextBlock. Set the text of this TextBlock to point to the string resource we just added. This can be done by using the syntax Text=”{StaticResource MyName}” as seen here:

<
TextBlock
Text
="{
StaticResource
MyName
}"></
TextBlock
>

转载地址:http://hvpvi.baihongyu.com/

你可能感兴趣的文章
MFC——子窗口之间传递参数和调用函数
查看>>
Ubuntu18.04安装NVIDIA显卡驱动
查看>>
Windows10配置darknet环境遇到的若干问题
查看>>
Libtorch部署模型
查看>>
雅虎采用开源搜索软件Hadoop 对抗谷歌
查看>>
李开复:新一代互联网的七大趋势
查看>>
丁磊“痛悔”网易上市 提醒企业家勿贪图虚荣
查看>>
说说大型高并发高负载网站的系统架构
查看>>
从LiveJournal后台发展看 大型网站系统架构以及性能优化方法
查看>>
使用开源软件,设计高性能可扩展互动网站
查看>>
BGP机房的优点
查看>>
大型web2.0互动网站设计方案
查看>>
常用开源协议解析
查看>>
MySQL查询优化讲座之管理员的优化措施
查看>>
程序员四大忌,你做到了吗?
查看>>
Yupoo! 的网站技术架构
查看>>
新浪发起的UNIX开源软件项目memcachedb
查看>>
豆瓣的程序性能真的很惊人,但...
查看>>
豆瓣的 Web 服务器
查看>>
优化PHP代码的40条建议
查看>>