windows phone7 开发 使用系统资源

webphp 13年前
     <p style="line-height:20px;margin:5px auto;font-family:georgia,verdana,Arial,helvetica,sans-seriff;color:#4b4b4b;font-size:13px;" align="left"><span style="line-height:19px;font-family:宋体;">如果要使用系统的资源,最简单的方法就是在</span>XAML<span style="line-height:19px;font-family:宋体;">中使用</span><span style="line-height:19px;font-family:NSimSun;color:#a31515;font-size:9.5pt;">StaticResource</span><span style="line-height:19px;font-family:宋体;color:#a31515;font-size:9.5pt;">;</span><span style="line-height:19px;font-family:宋体;color:black;font-size:9.5pt;">这在</span><span style="line-height:19px;font-family:NSimSun;color:black;font-size:9.5pt;">xaml</span><span style="line-height:19px;font-family:宋体;color:black;font-size:9.5pt;">文件中非常常见。如:</span></p>    <p style="line-height:20px;margin:5px auto;font-family:georgia,verdana,Arial,helvetica,sans-seriff;color:#4b4b4b;font-size:13px;" align="left"><span style="line-height:19px;font-family:NSimSun;color:red;font-size:9.5pt;">FontFamily</span><span style="line-height:19px;font-family:NSimSun;color:blue;font-size:9.5pt;">="{</span><span style="line-height:19px;font-family:NSimSun;color:#a31515;font-size:9.5pt;">StaticResource</span><span style="line-height:19px;font-family:NSimSun;color:red;font-size:9.5pt;"> PhoneFontFamilyNormal</span><span style="line-height:19px;font-family:NSimSun;color:blue;font-size:9.5pt;">}"</span></p>    <p style="line-height:20px;margin:5px auto;font-family:georgia,verdana,Arial,helvetica,sans-seriff;color:#4b4b4b;font-size:13px;" align="left"><span style="line-height:19px;font-family:NSimSun;color:red;font-size:9.5pt;">FontSize</span><span style="line-height:19px;font-family:NSimSun;color:blue;font-size:9.5pt;">="{</span><span style="line-height:19px;font-family:NSimSun;color:#a31515;font-size:9.5pt;">StaticResource</span><span style="line-height:19px;font-family:NSimSun;color:red;font-size:9.5pt;"> PhoneFontSizeNormal</span><span style="line-height:19px;font-family:NSimSun;color:blue;font-size:9.5pt;">}"</span></p>    <p style="line-height:20px;margin:5px auto;font-family:georgia,verdana,Arial,helvetica,sans-seriff;color:#4b4b4b;font-size:13px;" align="left"><span style="line-height:19px;font-family:NSimSun;color:red;font-size:9.5pt;">Foreground</span><span style="line-height:19px;font-family:NSimSun;color:blue;font-size:9.5pt;">="{</span><span style="line-height:19px;font-family:NSimSun;color:#a31515;font-size:9.5pt;">StaticResource</span><span style="line-height:19px;font-family:NSimSun;color:red;font-size:9.5pt;"> PhoneForegroundBrush</span><span style="line-height:19px;font-family:NSimSun;color:blue;font-size:9.5pt;">}"</span></p>    <p style="line-height:20px;margin:5px auto;font-family:georgia,verdana,Arial,helvetica,sans-seriff;color:#4b4b4b;font-size:13px;" align="left"><span style="line-height:19px;font-family:宋体;color:black;font-size:9.5pt;">在自已的工程中使用系统的预定义</span> <span style="line-height:19px;font-family:宋体;color:black;font-size:9.5pt;">资源,可以使风格与系统保持一致。由其是要想和设定的</span><span style="line-height:19px;font-family:NSimSun;color:black;font-size:9.5pt;">Theme</span><span style="line-height:19px;font-family:宋体;color:black;font-size:9.5pt;">保持一致,也可以说追着用户</span><span style="line-height:19px;font-family:NSimSun;color:black;font-size:9.5pt;">Theme</span><span style="line-height:19px;font-family:宋体;color:black;font-size:9.5pt;">的设置而使自已开发的应用一起变化的话,就必须要使用系统提供的资源了。不过对于</span><span style="line-height:19px;font-family:NSimSun;color:black;font-size:9.5pt;">Theme</span><span style="line-height:19px;font-family:宋体;color:black;font-size:9.5pt;">来说主要就有两个(</span><span style="line-height:19px;font-family:NSimSun;color:black;font-size:9.5pt;">background</span><span style="line-height:19px;font-family:宋体;color:black;font-size:9.5pt;">、</span><span style="line-height:19px;font-family:NSimSun;color:black;font-size:9.5pt;">accent color</span><span style="line-height:19px;font-family:宋体;color:black;font-size:9.5pt;">);所以在自已的工程中,如果要和</span><span style="line-height:19px;font-family:NSimSun;color:black;font-size:9.5pt;">Theme</span><span style="line-height:19px;font-family:宋体;color:black;font-size:9.5pt;">保持一致,就需要使用</span><span style="line-height:19px;font-family:NSimSun;color:black;font-size:9.5pt;">PhoneBackgroundBrush</span><span style="line-height:19px;font-family:宋体;color:black;font-size:9.5pt;">或</span><span style="line-height:19px;font-family:NSimSun;color:black;font-size:9.5pt;">PhoneBackgroundColor,PhoneAccentBrush</span><span style="line-height:19px;font-family:宋体;color:black;font-size:9.5pt;">或</span><span style="line-height:19px;font-family:NSimSun;color:black;font-size:9.5pt;">PhoneAccentColor</span><span style="line-height:19px;font-family:宋体;color:black;font-size:9.5pt;">。</span></p>    <p style="line-height:20px;margin:5px auto;font-family:georgia,verdana,Arial,helvetica,sans-seriff;color:#4b4b4b;font-size:13px;" align="left"><span style="line-height:19px;font-family:宋体;color:black;font-size:9.5pt;">另外,也可以通过代码来调用系统资源。</span></p>    <p style="line-height:20px;margin:5px auto;font-family:georgia,verdana,Arial,helvetica,sans-seriff;color:#4b4b4b;font-size:13px;" align="left"><span style="line-height:19px;font-family:NSimSun;font-size:9.5pt;">SystemColor = (<span style="color:#2b91af;">Color</span>)<span style="color:#2b91af;">Application</span>.Current.Resources[<span style="color:#a31515;">"PhoneAccentColor"</span>];</span></p>