wpf控件
- 布局
- 按钮
- button
- 数据显示
- 日期
- 菜单
- 选择
- 导航
- 对话框
- 用户消息
- 文档
- 输入
- 媒体
- 数字墨迹
WPF Windows
布局
Grid
。对于每一列,可以指定一个ColumnDefinition;对于每一行,可以指定一个RowDefinition。
- 简单控件
- 内容控件
- 带标题的内容控件
- 项控件
- 带标题的项控件
- 修饰控件
简单控件:没有Content 属性
PasswordBox
用于输入密码,有用于输入密码的专用属性,例如,PasswordChar 属性定义了在用户输入密码时显示的字符,Password 属性可以访问输入的密码。PasswordChanged 事件在修改密码时立即调用
Scrollbar
包含一个Thumb,用户可以从Thumb 中选择—个值。例如,如果文档在屏幕中放不下,就可以使用滚动条
ProgressBar
Slider
TextBox
RichTextBox
通过FlowDocument 类支持带格式的文本
Calendar
选择一个日期或日期范围
DatePicker
ContentControl内容控件:有Content 属性
ButtonBase
- Button
- RepeatButton:会重复引发Click 事件,直到释放按钮为止
- ToggleButton:有开关状态
- CheckBox:由用户选择和取消选择
- RadioButton:可以由用户选择,清除RadioButton的选择必须通过编程方式实现
Label
Frame
Frame 控件支持导航。使用Navigate()方法可以导航到一个页面内容上。如果该内容是一个网页,就使用浏览器控件来显示
ListBoxItem
StatusBoxItem
ScrollViewer
ToolTip
UserControl
将UserControl 类用作基类,可以为创建自定义控件提供一种简单方式。但是,基类UserControl 不支持模板
Window
NavigationWindow
HeaderedContentControl带标题的内容控件
Expander
使用Expander 控件,可以创建一个带对话框的“高级”模式,它在默认情况下不显示所有的信息,只有用户展开它,才会显示更多的信息。在未展开模式下,只显示标题信息;在展开模式下,显示内容
GroupBox
提供了边框和标题来组合控件
TabItem
ItemsControl项控件:包含一个可以用Items 属性访问的数据项列表
Menu
ContextMenu
StatusBar
TreeView
ListBox
ComboBox
有一个附带的Button 控件,只有单击该按钮,才会显示数据项
TabControl
内容可以排列为表格形式
DataGrid
显示数据的可定制网格
HeaderedItemsControl带标题的项控件
MenuItem
TreeViewItem
ToolBar
Decorator修饰控件
Border
Viewbox
BulletDecorator
对话框
消息框MessageBox
MessageBox.Show(string messageBoxText,string caption,MessageBoxButton button,MessageBoxImage icon);
MessageBoxResult result =MessageBox.Show(
"messageBoxText",
"caption",
MessageBoxButton.YesNoCancel,
MessageBoxImage.Warning
);
switch (result)
{
case MessageBoxResult.Yes:
// User pressed Yes button
// ...
break;
case MessageBoxResult.No:
// User pressed No button
// ...
break;
case MessageBoxResult.Cancel:
// User pressed Cancel button
// ...
break;
}
通用对话框
“打开文件”对话框OpenFileDialog
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
dlg.FileName = "Document"; // Default file name
dlg.DefaultExt = ".txt"; // Default file extension
dlg.Filter = "Text documents |*.txt"; // Filter files by extension
// Show open file dialog box
Nullable result = dlg.ShowDialog();
// Process open file dialog box results
if (result == true)
{
// Open document
string filename = dlg.FileName;
}
“保存文件”对话框SaveFileDialog
// Configure save file dialog box
Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
dlg.FileName = "Document"; // Default file name
dlg.DefaultExt = ".text"; // Default file extension
dlg.Filter = "Text documents|*.txt"; // Filter files by extension
// Show save file dialog box
Nullable result = dlg.ShowDialog();
// Process save file dialog box results
if (result == true)
{
// Save document
string filename = dlg.FileName;
}
“打印”对话框PrintDialog
// Configure printer dialog box
System.Windows.Controls.PrintDialog dlg = new System.Windows.Controls.PrintDialog();
dlg.PageRangeSelection = PageRangeSelection.AllPages;
dlg.UserPageRangeEnabled = true;
// Show save file dialog box
Nullable result = dlg.ShowDialog();
// Process save file dialog box results
if (result == true)
{
// Print document
}