Walkthrough: My first WPF desktop application
Walkthrough: My first WPF desktop application
This article shows you how to develop a Windows Presentation Foundation (WPF) desktop application that includes the elements that are common to most WPF applications:
Extensible Application Markup Language (XAML) markup, code-behind, application definitions, controls, layout, data binding, and styles. To develop the application, you'll use Visual Studio.
This walkthrough includes the following steps:
Use XAML to design the appearance of the application's user interface (UI).
Write code to build the application's behavior.
Create an application definition to manage the application.
Add controls and create the layout to compose the application UI.
Create styles for a consistent appearance throughout the application's UI.
Bind the UI to data, both to populate the UI from data and to keep the data and UI synchronized.
By the end of the walkthrough, you'll have built a standalone Windows application that allows users to view expense reports for selected people. The application is composed of several WPF pages that are hosted in a browser-style window.
Tip
The sample code that is used to build this walkthrough is available for both Visual Basic and C# at Walkthrough WPF App Sample Code.
You can toggle the code language of the sample code between C# and Visual Basic by using the </> drop-down on the upper right side of this article.
Create the application project
The first step is to create the application infrastructure, which includes an application definition, two pages, and an image.
Create a new WPF Application project in Visual Basic or Visual C# named
ExpenseIt:Open Visual Studio and select Create a new project under the Get started menu.
The Create a new project dialog opens.
In the Language dropdown, select either C# or Visual Basic.
Select the WPF App (.NET Framework) template and then select Next.
The Configure your new project dialog opens.
4.Enter the project name ExpenseIt and then select Create.
Visual Studio creates the project and opens the designer for the default application window named MainWindow.xaml.
2.Open Application.xaml (Visual Basic) or App.xaml (C#).
This XAML file defines a WPF application and any application resources.
You also use this file to specify the UI, in this case MainWindow.xaml, that automatically shows when the application starts.
Your XAML should look like the following in Visual Basic:
And like the following in C#:
StartupUri是启动文件
<Application x:Class="CardQuery.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:CardQuery"
StartupUri="MainWindow.xaml">
<Application.Resources> </Application.Resources>
</Application>
3.
Open MainWindow.xaml.
This XAML file is the main window of your application and displays content created in pages. The Window class defines the properties of a window, such as its title, size, or icon, and handles events, such as closing or hiding.
Walkthrough: My first WPF desktop application的更多相关文章
- WPF的Application类
本节主要介绍一下Application类的部分功能,我们首先来看一下如何使用Application类来加载一个窗口: 我们首先创建一个控制台程序,并引入相关的dll,然后修改Main()方法. [ST ...
- WPF之application对象
WPF:Application简介 Application是一个地址空间,在WPF中应用程序就是在System.Windows命名空间下的一个Application实例.一个应用程序只能对应一个App ...
- How to update WPF browser application manifest and xbap file with ‘mage.exe’
老外参考文章1 老外参考文章2 I created a WPF browser application MyApp then published it by ClickOnce in VS2008. ...
- 使用IE9、FireFox与Chrome浏览WPF Browser Application(.XBAP)的方式
最近开始写一些WPF的小Sample和文章,但是毕竟WPF应用程式不像Silverlight那么方便的只要装个Plugin就可以透过浏览器来看执行结果,因此把脑筋动到了改用WPF Browser Ap ...
- WPF 的 Application.Current.Dispatcher 中,为什么 Current 可能为 null
原文:WPF 的 Application.Current.Dispatcher 中,为什么 Current 可能为 null 在 WPF 程序中,可能会存在 Application.Current.D ...
- WPF 的 Application.Current.Dispatcher 中,Dispatcher 属性一定不会为 null
原文:WPF 的 Application.Current.Dispatcher 中,Dispatcher 属性一定不会为 null 在 WPF 程序中,可能会存在 Application.Curren ...
- WPF基础——Application
一.Application介绍 WPF中的Application对象用来进行一些全局的行为和操作,并且每个 Domain (应用程序域)中仅且只有一个 Application 实例存在.WPF App ...
- WPF入口Application
1.WPF和 传统的WinForm 类似, WPF 同样需要一个 Application 来统领一些全局的行为和操作,并且每个 Domain (应用程序域)中只能有一个 Application 实例存 ...
- 【WPF】Application应用程序启动
wpf应用程序在启动的时候会自动创建Main函数并调用Application实例的run(),从而启动Application进程.Main函数在一个App.g.cs文件中,App.g.cs文件的位置在 ...
随机推荐
- GitHub使用--01
1.Git下载与安装 Git网站下载地址https://git-scm.com/downloads 2.本地Git使用 在存储代码仓库的文件夹下右键 git bash here 初始化仓库 git i ...
- ssh登录缓慢,使用ssh -v登录后,显示在 “pledge: network” 处卡顿:
当登录一台服务器时,每次输入密码之后都要等很久才会得到命令提示符,尝试修改了sshd_config中的UseDNS no,但效果依然不好. ssh -v 192.168.12.43 This is p ...
- mybatis框架中 #和$传递参数的区别 和注意
#{}: 1. 是预编译 2. 编译成占位符 3. 可以防止sql注入 4. 自动判断数据类型 5. 一个参数时,可以使用任意参数名称进行接收 ${}: 1. 非预编译 2. sql的直 ...
- DA_04_解决Xshell中文乱码问题
一:解决Xshell中文乱码问题 二:解决克隆后eth0不见的问题 2.1:虚拟机克隆步骤: 1.直接修改 /etc/sysconfig/network-script/i ...
- RabbitMQ各种交换机类型Exchange Types介绍
最新版本的RabbitMQ有四种交换机类型,分别是Direct exchange.Fanout exchange.Topic exchange.Headers exchange. 一.Direct E ...
- Android异常与性能优化相关面试问题-冷启动优化面试问题详解
什么是冷启动: 冷启动的定义:冷启动就是在启动应用前,系统中没有该应用的任何进程信息.实际也就是要执行Application.onCreate()方法的那次启动. 冷启动 / 热启动的区别:热启动:用 ...
- libusb_bulk_transfer 说明
libusb_bulk_transfer函数说明 API_EXPORTED int libusb_bulk_transfer(struct libusb_device_handle *dev_ha ...
- Cloneable测试
一.Cloneable 的用途 Cloneable和Serializable一样都是标记型接口,它们内部都没有方法和属性,implements Cloneable表示该对象能被克隆,能使用Obje ...
- 第二章 Vue快速入门--8 v-bind指令的学习
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8&quo ...
- BZOJ2118 墨墨的等式[同余类最短路]
声明:关于这题的$O(mn)$尚且未深入理解,虽然之前有跟这位神仙聊过做法但并没太懂.. $O(mn\log m)$同余最短路做法: 首先不妨抽出最小的$a_i=m$,那么剩余的$a$如果可以表示出$ ...