WPF 样式、模板与用户控件开发指南
1. 样式基础与创建
样式的最终目标是定义一个 Style 对象,该对象至少要用一组属性/值对填充 Setters 集合。以下是创建一个捕获应用程序中控件基本字体特征的样式示例。
打开 App.xaml 文件,使用 Blend XAML 编辑器定义以下样式(通过键 BasicControlStyle 标识):
<Application
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="WpfStyleByHand.App"
StartupUri="MainWindow.xaml">
<!-- 这是一个非常简单的样式,可应用于任何控件。 -->
<Application.Resources>
<Style x:Key ="BasicControlStyle">
<Setter Property = "Control.FontSize" Value ="14"/>
<Setter Property = "Control.Height" Value = "40"/>
<Setter Property = "Control.C
超级会员免费看
订阅专栏 解锁全文
629

被折叠的 条评论
为什么被折叠?



