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文件的位置在 ...
随机推荐
- php操作 cookie
1,设置cookie <?php setcookie('key'); setcookie('key1','value1'); setcookie(***); setcookie('key4', ...
- docker 批量删除含有同样名字的images
docker rmi --force $(docker images | grep doss-api | awk '{print $3}') docker rmi $(docker images | ...
- Nginx返回大长度的JSON数据被截断
1 添加Nginx参数,增加缓存字符串大小 head{ proxy_buffers 16 512k; //此处值代表nginx 设置 16个 512k 的块进行缓存,总共大小为16*512k prox ...
- zookeeper--为分布式应用提供协调服务
1.概述 zookeeper是一个开源的.分布式的.为分布式应用提供协调服务的Apache项目 zookeeper的工作机制 zookeeper从设计模式角度来理解:是一个基于观察者模式设计的分布式服 ...
- visio的形状默认是蓝色的填充色,怎么设置为白色为默认色?
如图所示: 设计->主题->选黑白那个 效果如下:
- Java高级技术点面试问题-IO相关面试问题
java网络编译: 基础知识:①.ip地址和端口号:ip地址是用来识别网络中的一个实体,而这个实体可以理解为一个主机,而端口号则是用来区分具体的通讯程序的.②.tcp / udp协议:tcp是一个可靠 ...
- 纯c中声明变量
count 声明位置错了,纯c中声明变量全部放在main函数里,最前面的位置,要么vc6.0会报错: 修改 #include <stdio.h> int main(void) { int ...
- MySQL 将数据文件分布到不同的磁盘
https://blog.csdn.net/john_chang11/article/details/51783632 [root@test1 temp]# vi /etc/my.cnf [mysql ...
- asp.net大文件传输断点续传源码
HTML部分 <%@PageLanguage="C#"AutoEventWireup="true"CodeBehind="index.aspx. ...
- UVA 315 求割点 模板 Tarjan
D - D Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submit Status Pract ...