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文件的位置在 ...
随机推荐
- 微信小程序onLoad、onShow、onHide、onUnload区别
onLoad:页面第一次加载时触发,从跳转页面返回时不能触发,可以传递参数 onShow:页面显示或从后台跳回小程序时显示此页面时触发,从跳转页面返回时触发,不能传递参数 onHide:页面隐藏,例如 ...
- 修改Vue中的 v-html 内的元素无效问题
其原因就是在 style 样式中没有去处scoped 因为 v-html 会把内容当成子组件,而scoped 会在本身的组件中起作用
- MySQL的基本操作一
本文主要涉及到的SQL知识点包括CREATE创建数据库和表.INSERT插入数据.SUM()求和.GROUP BY分组.DATE_FORMAT()格式化日期.ORDER BY排序.COUNT()统计行 ...
- SpringBoot-自动配置
一.自动配置的核心 一般springboot程序,我们都会在主启动类上加上@SpringBootApplication注解,@SpringBootApplication是一个复合注解,上面标注了@Co ...
- 3、Rsync备份服务实战
1.Rsync基本概述 rsync是一款开源的备份工具,可以在不同主机之间进行同步,可实现全量备份与增量备份,因此非常适合用于架构集中式备份或异地备份等应用. rsync官方地址:传送门http:// ...
- 9月24日开始发布,主打安全的Librem 5 Linux手机
曾推出搭载PureOS Linux发行版本Librem笔记本系列的硬件厂商Purism,今天正式宣布了Librem 5 Linux手机的最终和官方发售日期.Librem 5于2017年10月正式发布, ...
- EEPROM原理详解
EEPROM(Electrically Erasable Programmable read only memory)即电可擦可编程只读存储器,是一种掉电后数据不丢失(不挥发)存储芯片. EERPOM ...
- Easy UI 入门
Easy UI常用于企业级开发的UI和后台开发的UI,比较重. 以下组件中的加载方式,属性和事件,方法和组件种类并不全,只是作为参考和入门学习. 1.Draggable(拖动)组件 不依赖其他组件 1 ...
- 第六章 组件 67 使用ref获取DOM元素和组件引用
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8&quo ...
- linux禁止普通用户登录
要想禁止普通用户登录 方法如下: 在 /etc下创建一个 nologin的文件 编辑这个文件,输入内容,当普通用户登录时就会提示这个文件的内容,并且禁止登陆. 执行步骤: touch /etc/nol ...