Files
2026-10-27 09:12:40 +08:00

14 KiB

原生 WPF 控件样式

这里处理 System.Windows.Controls 的原生类型。需要扩展控件功能时才选 HandyControl.Controls 下的类型。先按实际 CLR 类型选择样式,不能将一个同名扩展类型的样式套在原生类型上。

<StackPanel>
    <Button Content="保存" Style="{StaticResource ButtonPrimary}"
            Command="{Binding SaveCommand}"/>
    <TextBox Margin="0,12,0,0" Style="{StaticResource TextBoxExtend}"
             hc:InfoElement.Title="用户名" hc:InfoElement.Placeholder="请输入用户名"
             Text="{Binding UserName, UpdateSourceTrigger=PropertyChanged}"/>
</StackPanel>

片段依赖 App.xaml 的皮肤和主题字典、hc 命名空间,以及使用方 DataContext。原生 PasswordBox 不提供可直接按 TextBox 方式绑定的 Text 属性;需要密码绑定时按实际控件方案实现。

附加属性来自 Controls/Attach:检查 InfoElement、TitleElement、BorderElement、IconElement 等的 Get/Set 方法和对应模板的使用位置。设置附加属性不代表任意模板都会展示它。

下面的显式 Style 键从本仓库各原生控件样式源文件生成;不是所有键都适用于控件本身(例如某些键针对子元素),使用前在源文件核对 TargetType。隐式样式和 BasedOn 链不在本清单展开。

border

src/Shared/HandyControl_Shared/Themes/Styles/Border.xaml

显式样式键:BorderRegion、BorderTipBaseStyle、BorderTipPrimary、BorderTipDanger、BorderTipWarning、BorderTipInfo、BorderTipSuccess、BorderVerticallySplitter、BorderHorizontallySplitter、BorderCircular、BorderClip、BorderCircularClip

button

src/Shared/HandyControl_Shared/Themes/Styles/Button.xaml

显式样式键:ButtonDefault、ButtonDefault.Small、ButtonPrimary、ButtonPrimary.Small、ButtonSuccess、ButtonSuccess.Small、ButtonInfo、ButtonInfo.Small、ButtonWarning、ButtonWarning.Small、ButtonDanger、ButtonDanger.Small、ButtonIcon、ButtonIcon.Small、ButtonIconCircular、ButtonIconCircular.Small、ButtonDashed、ButtonDashed.Small、ButtonDashedPrimary、ButtonDashedPrimary.Small、ButtonDashedSuccess、ButtonDashedSuccess.Small、ButtonDashedInfo、ButtonDashedInfo.Small、ButtonDashedWarning、ButtonDashedWarning.Small、ButtonDashedDanger、ButtonDashedDanger.Small、ButtonCustom、ButtonGroupItemDefault、ButtonGroupItemHorizontalFirst、ButtonGroupItemHorizontalLast、ButtonGroupItemSingle、ButtonGroupItemVerticalFirst、ButtonGroupItemVerticalLast

calendar

src/Shared/HandyControl_Shared/Themes/Styles/Calendar.xaml

显式样式键:CalendarButtonStyle、CalendarDayButtonStyle、CalendarBaseStyle

checkBox

src/Shared/HandyControl_Shared/Themes/Styles/CheckBox.xaml

显式样式键:

comboBox

src/Shared/HandyControl_Shared/Themes/Styles/ComboBox.xaml

显式样式键:ComboBoxItem.Small、ComboBox.Small、ComboBoxExtend、ComboBoxExtend.Small、ComboBoxPlus.Small

contentControl

src/Shared/HandyControl_Shared/Themes/Styles/ContentControl.xaml

显式样式键:

contextMenu

src/Shared/HandyControl_Shared/Themes/Styles/ContextMenu.xaml

显式样式键:ContextMenu.Small

dataGrid

src/Shared/HandyControl_Shared/Themes/Styles/DataGrid.xaml

显式样式键:DataGridBaseStyle、DataGridCellStyle.Small、DataGridRowStyle.Small、DataGridColumnHeaderStyle.Small、DataGrid.Small

datePicker

src/Shared/HandyControl_Shared/Themes/Styles/DatePicker.xaml

显式样式键:DatePicker.Small、DatePickerExtend、DatePickerExtend.Small、DatePickerPlus.Small

expander

src/Shared/HandyControl_Shared/Themes/Styles/Expander.xaml

显式样式键:Expander.Small

flowDocument

src/Shared/HandyControl_Shared/Themes/Styles/FlowDocument.xaml

显式样式键:

frame

src/Shared/HandyControl_Shared/Themes/Styles/Frame.xaml

显式样式键:

groupBox

src/Shared/HandyControl_Shared/Themes/Styles/GroupBox.xaml

显式样式键:GroupBox.Small、GroupBoxOriginal、GroupBoxTab、GroupBoxTab.Small

label

src/Shared/HandyControl_Shared/Themes/Styles/Label.xaml

显式样式键:LabelDefault、LabelDefault.Small、LabelPrimary、LabelPrimary.Small、LabelSuccess、LabelSuccess.Small、LabelInfo、LabelInfo.Small、LabelWarning、LabelWarning.Small、LabelDanger、LabelDanger.Small

listBox

src/Shared/HandyControl_Shared/Themes/Styles/ListBox.xaml

显式样式键:ListBoxItemBaseStyle.Small、ListBox.Small、ListBoxItemCustom、ListBoxCustom、WrapPanelHorizontalListBox、WrapPanelVerticalListBox、StackPanelHorizontalListBox、StackPanelVerticalListBox

listView

src/Shared/HandyControl_Shared/Themes/Styles/ListView.xaml

显式样式键:ListViewBaseStyle、ListViewItemBaseStyle.Small、ListView.Small

menu

src/Shared/HandyControl_Shared/Themes/Styles/Menu.xaml

显式样式键:Menu.Small

passwordBox

src/Shared/HandyControl_Shared/Themes/Styles/PasswordBox.xaml

显式样式键:PasswordBox.Small、PasswordBoxExtend、PasswordBoxExtend.Small、PasswordBoxPlus.Small

progressBar

src/Shared/HandyControl_Shared/Themes/Styles/ProgressBar.xaml

显式样式键:ProgressBarSuccess、ProgressBarInfo、ProgressBarWarning、ProgressBarDanger、ProgressBarPrimaryStripe、ProgressBarSuccessStripe、ProgressBarInfoStripe、ProgressBarWarningStripe、ProgressBarDangerStripe、ProgressBarSuccessCircle、ProgressBarInfoCircle、ProgressBarWarningCircle、ProgressBarDangerCircle、ProgressBarSuccessWave、ProgressBarInfoWave、ProgressBarWarningWave、ProgressBarDangerWave、ProgressBarFlat

radioButton

src/Shared/HandyControl_Shared/Themes/Styles/RadioButton.xaml

显式样式键:RadioButtonSameAsButtonDefault、RadioButtonSameAsButtonDefault.Small、RadioButtonSameAsButtonPrimary、RadioButtonSameAsButtonPrimary.Small、RadioButtonSameAsButtonSuccess、RadioButtonSameAsButtonSuccess.Small、RadioButtonSameAsButtonInfo、RadioButtonSameAsButtonInfo.Small、RadioButtonSameAsButtonWarning、RadioButtonSameAsButtonWarning.Small、RadioButtonSameAsButtonDanger、RadioButtonSameAsButtonDanger.Small、RadioButtonIcon、RadioButtonIcon.Small、RadioGroupItemDefault、RadioGroupItemHorizontalFirst、RadioGroupItemHorizontalLast、RadioGroupItemSingle、RadioGroupItemVerticalFirst、RadioGroupItemVerticalLast

richTextBox

src/Shared/HandyControl_Shared/Themes/Styles/RichTextBox.xaml

显式样式键:TextBoxBaseBaseStyle、RichTextBoxBaseStyle

scrollViewer

src/Shared/HandyControl_Shared/Themes/Styles/ScrollViewer.xaml

显式样式键:ScrollViewerUpDownRepeatButtonStyle、ScrollViewerUpDown

separator

src/Shared/HandyControl_Shared/Themes/Styles/Separator.xaml

显式样式键:

slider

src/Shared/HandyControl_Shared/Themes/Styles/Slider.xaml

显式样式键:

statusBar

src/Shared/HandyControl_Shared/Themes/Styles/StatusBar.xaml

显式样式键:

tabControl

src/Shared/HandyControl_Shared/Themes/Styles/TabControl.xaml

显式样式键:TabItemSliding、TabControlSliding、TabItemInLine、TabControlInLine、TabItemCapsuleDefault、TabItemCapsuleHorizontalFirst、TabItemCapsuleHorizontalLast、TabItemCapsuleSingle、TabItemCapsuleVerticalFirst、TabItemCapsuleVerticalLast、TabControlCapsule、TabControlCapsuleSolid

textBlock

src/Shared/HandyControl_Shared/Themes/Styles/TextBlock.xaml

显式样式键:TextBlockDefault、TextBlockDefaultAccent、TextBlockDefaultPrimary、TextBlockDefaultDanger、TextBlockDefaultWarning、TextBlockDefaultInfo、TextBlockDefaultSuccess、TextBlockDefaultSecLight、TextBlockDefaultThiLight、TextBlockLarge、TextBlockTitle、TextBlockSubTitle、TextBlockLargeBold、TextBlockTitleBold、TextBlockSubTitleBold、TextBlockDefaultBold

textBox

src/Shared/HandyControl_Shared/Themes/Styles/TextBox.xaml

显式样式键:TextBox.Small、TextBoxExtend、TextBoxExtend.Small、TextBoxPlus.Small

toggleButton

src/Shared/HandyControl_Shared/Themes/Styles/ToggleButton.xaml

显式样式键:ToggleButtonDefault、ToggleButtonDefault.Small、ToggleButtonPrimary、ToggleButtonPrimary.Small、ToggleButtonSuccess、ToggleButtonSuccess.Small、ToggleButtonInfo、ToggleButtonInfo.Small、ToggleButtonWarning、ToggleButtonWarning.Small、ToggleButtonDanger、ToggleButtonDanger.Small、ToggleButtonIcon、ToggleButtonIcon.Small、ToggleButtonIconPrimary、ToggleButtonIconPrimary.Small、ToggleButtonIconSuccess、ToggleButtonIconSuccess.Small、ToggleButtonIconInfo、ToggleButtonIconInfo.Small、ToggleButtonIconWarning、ToggleButtonIconWarning.Small、ToggleButtonIconDanger、ToggleButtonIconDanger.Small、ToggleButtonIconTransparent、ToggleButtonIconTransparent.Small、ToggleButtonSwitch、ToggleButtonSwitch.Small、ToggleButtonFlip、ToggleButtonFlip.Small、ToggleButtonCustom、ToggleButtonGroupItemDefault、ToggleButtonGroupItemHorizontalFirst、ToggleButtonGroupItemHorizontalLast、ToggleButtonGroupItemSingle、ToggleButtonGroupItemVerticalFirst、ToggleButtonGroupItemVerticalLast、ToggleButtonLoadingPrimary、ToggleButtonLoading、ToggleButtonLoadingSuccess、ToggleButtonLoadingInfo、ToggleButtonLoadingWarning、ToggleButtonLoadingDanger

toolBar

src/Shared/HandyControl_Shared/Themes/Styles/ToolBar.xaml

显式样式键:

toolTip

src/Shared/HandyControl_Shared/Themes/Styles/ToolTip.xaml

显式样式键:

treeView

src/Shared/HandyControl_Shared/Themes/Styles/TreeView.xaml

显式样式键:TreeViewItemBaseStyle.Small、TreeView.Small

window

src/Shared/HandyControl_Shared/Themes/Styles/Window.xaml

显式样式键:WindowWin10、WindowBlur、WindowGlow