急 !C# WPF 中如何在App.xaml中对不同操作系统设置TextBox的字体大小
<Style TragetType="{x:Type Control}" x:Key="win7TextBoxStyle"><Setter Property="FontSize" Value="10">
</Style>
<Style TargetType="{x:Type Control:CDataField} BasedOn="{StaticResource win7TextBoxStyle}"></Style>
我还想设一个CDataField在Windows XP下的FontSize = 11;
这样要在App中怎么写个代码让程序能区别出应该用哪个字体大小呢。
跪求!!! --------------------编程问答--------------------
/// <summary>
/// App.xaml 的交互逻辑
/// </summary>
public partial class App : Application
{
private void Application_Startup(object sender, StartupEventArgs e)
{
}
}
在程序启动事件里 Application_Startup 写 判断系统 逻辑
然后你的资源字典里 放几套 样式模版 比如 xp 的 window7的 两套
判断出系统后 用一个全局静态变量 记录 你要默认加载的模版格式
加载样式的时候 根据这个 全局静态变量 在load事件里 动态加载样式表 --------------------编程问答-------------------- 资源字典 你可以理解成 同名样式表的 两个样式表库
资源字典1
<Style TragetType="{x:Type TextBlock}" x:Key="TextBoxStyle">
<Setter Property="FontSize" Value="10">
</Style>
资源字典2
<Style TragetType="{x:Type TextBlock}" x:Key="TextBoxStyle">
<Setter Property="FontSize" Value="11">
</Style>
<TextBlock Style="{DynamicResource TextBoxStyle}"/>
当前窗体加载事件里 写你自己的逻辑 加载字典1 就是10 加载字典2 就是11字体
补充:.NET技术 , C#