WPF UI控件介绍

By | 2019-10-28

原文: https://blog.csdn.net/baidu_24565387/article/details/100189767

布局控件:是任何用户界面的基础,排列应用中的 UI 元素。 文本、按钮和图像等元素都需要规定自己位置和行为方式,构建基块称为“控件”,有时亦称为“元素”。

<Window x:Class="UsingLayoutsApp.Wpf.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:UsingLayoutsApp.Wpf"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
    </Grid>
</Window>

父元素和子元素

Window 元素只支持包含一个子元素。 Grid 元素支持包含所需的任意多个子元素。 Grid 是用途最广泛的布局元素之一。 它通常用作应用页面的主布局控件。

常用控件

  1. Grid 网格控件 可包含多个子控件
  2. StackPanel 是将项彼此堆叠在一起的简单布局控件,StackPanel 的默认堆叠策略是垂直
  3. DockPanel
  4. WrapPanel
  5. TextBlock 只读文本框
  6. DataGrid 列表数据显示控件
  7. ListView(可用DataGrid代替)
  8. ListBox
  9. GroupBox
  10. MediaElement
  11. Menu
  12. TabControl
图片来自互联网

发表评论

邮箱地址不会被公开。 必填项已用*标注