WPF 常用控件属性

基础控件 转载 原文链接:https://blog.csdn.net/sheila_1988/java/article/details/7278638

§按钮:Button 和 RepeatButton 。
§对话框: OpenFileDialog 、 PrintDialog和 SaveFileDialog。
§数字墨迹: SaveFileDialog和 InkPresenter。
§文档:DocumentViewer、FlowDocumentPageViewer、FlowDocumentReader、FlowDocumentScrollViewer 和 StickyNoteControl。
§输入:TextBox、RichTextBox 和 PasswordBox。
§布局:Border、BulletDecorator、Canvas、DockPanel、Expander、Grid、GridView、GridSplitter、GroupBox、Panel、ResizeGrip、Separator、ScrollBar、ScrollViewer、StackPanel、Thumb、Viewbox、VirtualizingStackPanel、Window 和 WrapPanel。
§媒体:Image、MediaElement 和 SoundPlayerAction。
§菜单:ContextMenu、Menu 和 ToolBar。
§导航:Frame、Hyperlink、Page、NavigationWindow 和 TabControl。
§选择:CheckBox、ComboBox、ListBox、TreeView、RadioButton 和 Slider。
§用户信息:AccessText、Label、Popup、ProgressBar、StatusBar、TextBlock 和 ToolTip。
§自定义控件:UserControl

1、高度和宽度
    不同尺寸的默认值:
    MinHeight     MaxHeight     Height
    MinWidth     MaxWidth     Width
    0     Infinity     NaN/Auto(自动)
    其他尺寸:
    DesiredSize
    RenderSize
    ActualHeight/ActualWidth

    FontSize  获取或设置字号。

   FontWeight    获取或设置指定的字体的权重或粗细。

   Foreground   获取或设置描述前景色的画笔。

   Background   获取或设置描述背景色的画笔。

   Width     获取或设置元素的宽度。

   Height    获取或设置元素的建议高度。

   Height    获取或设置元素的建议高度。


2、边框距离
    Margin:元素边界以外的空间大小
    Padding:元素边界以内的空间大小
    可以用1-4个数字来设置Margin和Padding的属性,数字相对应的属性顺序为:Left,Top,Right,Bottom
    相应C#代码:****.Margin = new Thickness(10);
3、可见性
    Visibility
    值:
    可见:visible
    折叠:Collapsed(不占布局)
    隐藏:Hidden(占布局)
4、对齐
    HorizontalAlignment:Left, Center, Right, Stretch(默认)
    VertiacalAlignment:Top, Center, Bottom, Stretch(默认)
5、内容对齐
    HorizontalContentAlignment:Left(默认), Center, Right, Stretch
    VertiacalContentAlignment:Top(默认), Center, Bottom, Stretch
6、流方向
    FlowDirection
    值:
    LefttoRight(默认):从左至右
    RighttoLeft:从右至左

1.TextBox

① ToolTip          该属性主要用于添加控件的提示信息(当鼠标移到该控件上时,会显示提示信息.)其他控件也有这个属性

② TabIndex        该属性用于设置Tab键的值。(当每个控件都设置该属性的值时,依次按键盘“Tab” 键,会根据设置的值依次聚焦到各个控件上)

③ TextWrapping    该属性设置成“Wrap”时,当输入字符到达某一行末尾时,再输入字符时自动跳到下一行。

④ AcceptsReturn   该属性为设置为“True”时 ,回车会换行,“false”时忽略回车换行。

⑤ IsHitTestVisible   可以不使用该属性。当使用时属性设置为“False”时,点击该框,无法定位,无法向该框输入内容。

⑥ VerticalContentAlignment  该属性主要设置用户输入的内容在该框中哪个位置。

⑦  Text           该属性用于绑定该控件的内容。

⑧ VerticalScrollBarVisibility和ScrollViewer.VerticalScrollBarVisibility  这两个属性值都设为“Visible”时,右面的滚动条才可见。

2.TextBlock

① <Run Foreground="Red">*</Run>

        <Run>ID:</Run>    用于标红(或其他色)星号

3.ComboBox

① SelectedValue   绑定选中的一个信息.

② SelectedValuePath  根据***选择该值.

③ ItemSource  绑定控件下拉的所有信息.

④ DisPlayMemberPath   根据***显示下拉信息.

⑤ IsEditable     是否可编辑。

⑥ OpenDropDownOnFocus    打开时是否显示下拉框。

⑦ CanAutocompleteSelectItems  能否自动补全。

⑧ CanKeyboaedNavigationSelectItems   是否允许键盘输入匹配选择。

⑨ IsTextSearchEnabled   是否文本可以选择。

 

 

原文地址:https://www.cnblogs.com/-wqq/p/12979384.html