001集—— 创建一个WPF项目 ——WPF应用程序入门 C#

本例为一个WPF应用(.NET FrameWork)。

首先创建一个项目

双击xaml文件

双击xaml文件进入如下界面,开始编写代码。

效果如下:

付代码:

cs 复制代码
<Window x:Class="WpfDemoFW.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:WpfDemoFW" 
        mc:Ignorable="d"
        Title="这是一个WPF的演示" Height="550" Width="600">
    <Grid ShowGridLines="True" >
        <Grid.RowDefinitions >
            <RowDefinition Height=" 30"/>
            <RowDefinition Height=" 30"/>
            <RowDefinition/>
            <RowDefinition Height=" 30"/>
            <RowDefinition Height=" 30"/>
        </Grid.RowDefinitions>
       
        <StackPanel Grid.Row=" 0" Grid.Column=" 0" Orientation="Horizontal">
            <Button Width=" 40" Height=" 20" Content=" 文件"  />
            <Button Width=" 40" Height=" 20" Content=" 编辑" />
            <Button Width=" 40" Height=" 20" Content=" 视图" />
            <Button Width=" 40" Height=" 20" Content=" Git(G)" />
            <Button Width=" 40" Height=" 20" Content="项目" />
            <Button Width=" 40" Height=" 20" Content="生成" />
            <Button Width=" 40" Height=" 20" Content="调试" />
            <Button Width=" 40" Height=" 20" Content="测试" />
        </StackPanel>
        <StackPanel Grid.Row=" 1" Grid.Column=" 0" Orientation="Horizontal">
            <Button Width=" 130" Height=" 20" Content="MainWindow.xaml"  HorizontalAlignment="Left"  />
            <Button Width=" 140" Height=" 20" Content=" MainWindow.xaml.cs" HorizontalAlignment="Right" />
        </StackPanel>
        <Grid  Grid.Row=" 2" Grid.Column=" 0" Background="CadetBlue" >
            <Grid.ColumnDefinitions >
                <ColumnDefinition Width=" 70"/>
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <StackPanel Grid.Column=" 0" Grid.Row=" 0">
                <Button  Height=" 20" Content="1"/>
                <Button  Height=" 20" Content="2"/>
                <Button  Height=" 20" Content="3"/>
                <Button  Height=" 20" Content="4"/>
            </StackPanel>
            <RichTextBox   Grid.Row=" 0" Grid.Column=" 1"/>
        </Grid>
        <Grid Grid.Row=" 3" Grid.Column=" 0" >
            <Grid.ColumnDefinitions >
                <ColumnDefinition />
                <ColumnDefinition />
                <ColumnDefinition />
                <ColumnDefinition />
                
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <Button Grid.Column ="0"  Width=" 120" Height=" 20" Content="程序包管理器控制台"  HorizontalAlignment="Left"  />
            <Button Grid.Column ="1" Width=" 120" Height=" 20" Content="输出"  HorizontalAlignment="Left"  />
            <Button Grid.Column ="2" Width=" 120" Height=" 20" Content="错误列表"  HorizontalAlignment="Left"  />
            
        </Grid>
        <StackPanel Grid.Row=" 4" Grid.Column=" 0" Orientation="Horizontal">
            <Button Width=" 130" Height=" 20" Content="就绪"  HorizontalAlignment="Left"  />
        </StackPanel>
    </Grid>
</Window>
相关推荐
玉面小君2 天前
从 WPF 到 Avalonia 的迁移系列实战篇6:Trigger、MultiTrigger、DataTrigger 的迁移
wpf·avalonia
招风的黑耳3 天前
Java生态圈核心组件深度解析:Spring技术栈与分布式系统实战
java·spring·wpf
lfw20193 天前
WPF 数据绑定模式详解(TwoWay、OneWay、OneTime、OneWayToSource、Default)
wpf
Magnum Lehar3 天前
3d wpf游戏引擎的导入文件功能c++的.h实现
3d·游戏引擎·wpf
FuckPatience3 天前
WPF Telerik.Windows.Controls.Data.PropertyGrid 自定义属性编辑器
wpf
almighty274 天前
C#WPF控制USB摄像头参数:曝光、白平衡等高级设置完全指南
开发语言·c#·wpf·usb相机·参数设置
军训猫猫头4 天前
12.NModbus4在C#上的部署与使用 C#例子 WPF例子
开发语言·c#·wpf
我要打打代码4 天前
在WPF项目中使用阿里图标库iconfont
wpf
拾忆,想起5 天前
Redisson 分布式锁的实现原理
java·开发语言·分布式·后端·性能优化·wpf
weixin_464078075 天前
wpf依赖注入驱动的 MVVM实现(含免费源代码demo)
wpf