WPF 与Surface 2.0 SDK 亲密接触
本篇将为大家介绍如何使用ScatterView 控件实现上述功能。由于触屏技术只在Windows 7 操作系统中支持,所以XP 的用户必须要升级到Windows 7 系统。首先,需要在Windows 7 中安装Surface 2.0 SDK 和Runtime,可到官方页面下载安装程序。安装完成后打开VS2010
本篇将为大家介绍如何使用ScatterView 控件实现上述功能。由于触屏技术只在Windows 7 操作系统中支持,所以XP 的用户必须要升级到Windows 7 系统。首先,需要在Windows 7 中安装Surface 2.0 SDK 和Runtime,可到官方页面下载安装程序。安装完成后打开VS2010 新建一个Surface 2.0 项目。在模板中选择Surface Appliction(WPF)。我们可以在当前的XAML 代码中添加一个Label 控件。F5 运行后Label 控件是无法进行Manipulating 操作的。
<span><span>s</span><span>:</span><span>SurfaceWindow </span><span>x</span><span>:</span><span>Class</span><span>="ScatterView.SurfaceWindow1" </span><span>xmlns</span><span>="http://schemas.microsoft.com/winfx/2006/xaml/presentation" </span><span>xmlns</span><span>:</span><span>x</span><span>="http://schemas.microsoft.com/winfx/2006/xaml" </span><span>xmlns</span><span>:</span><span>s</span><span>="http://schemas.microsoft.com/surface/2008" </span><span>Title</span><span>="ScatterView" > <span>Grid</span><span>> <span>Label </span><span>Content</span><span>="Surface 2.0" </span><span>Foreground</span><span>="Fuchsia" </span><span>FontWeight</span><span>="Bold"/> </span><span>Grid</span><span>> </span><span>s</span><span>:</span><span>SurfaceWindow</span><span>> </span></span></span></span>

接下来在Grid 中添加一个ScatterView 控件。我们可以将ScatterView 认为是一个容器能够包含其他控件,并且这些控件均可以实现Manipulating 效果。例如,我们在ScatterView 中加入Rectangle、Label、SurfaceTextBox 三个控件。有些朋友可能会问Rectangle 为什么要放在ScatterViewItem 里?其实,所有在ScatterView 里的控件默认都会自动加入到ScatterViewItem,所以如果不需要特别设置可以将ScatterViewItem 控件省略。本例中我为了调整Rectangle 的减速数值就需要手动写出ScatterViewItem 控件,并调整Deceleration 参数。
<span><span>Grid</span><span>> <span>s</span><span>:</span><span>ScatterView </span><span>x</span><span>:</span><span>Name</span><span>="mainScatterView"> <span>s</span><span>:</span><span>ScatterViewItem </span><span>Deceleration</span><span>="50"> <span>Rectangle </span><span>Fill</span><span>="Green" </span><span>Width</span><span>="200" </span><span>Height</span><span>="100"/> </span><span>s</span><span>:</span><span>ScatterViewItem</span><span>> <span>Label </span><span>Content</span><span>="Surface 2.0" </span><span>Foreground</span><span>="Fuchsia" </span><span>FontWeight</span><span>="Bold"/> <span>s</span><span>:</span><span>SurfaceTextBox </span><span>Width</span><span>="500" </span><span>Height</span><span>="20" </span><span>FontSize</span><span>="20"/> </span><span>s</span><span>:</span><span>ScatterView</span><span>> </span><span>Grid</span><span>> </span></span></span></span></span></span></span>
完成上面代码后,F5 再运行一次。感觉如何?Manipulating 效果是不是变得很简单了... ...
如果有需要可以自动加载控件到ScatterView,下面代码将自动加入一张本机图片到程序中。
<span>private void </span>AddDemoPic() { <span>string </span>targetPic = <span>@"C:\Users\Public\Pictures\Sample Pictures\Koala.jpg"</span>; <span>ScatterViewItem </span>item = <span>new </span><span>ScatterViewItem</span>(); mainScatterView.Items.Add(item); <span>MediaElement </span>pic = <span>new </span><span>MediaElement</span>(); item.Content = pic; item.Background = <span>Brushes</span>.Transparent; <span>if </span>(System.IO.<span>File</span>.Exists(targetPic)) { pic.Source = <span>new </span><span>Uri</span>(targetPic); } <span>else </span>{ item.Content = <span>"Picture not found"</span>; } }
至此,本篇关于ScatterView 的介绍就到这里,欢迎大家相互交流。
相关参考
ScatterView Class
作者:李敬然(Gnie)
出处:{GnieTech} (http://www.cnblogs.com/gnielee/)

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



According to news on September 8, Microsoft announced in April this year that it would stop producing and selling Microsoft-branded accessories, including mice, keyboards, and cameras, and would focus on Surface-branded computer accessories in the future. Not long ago, foreign technology media mspoweruser reported an update on Microsoft’s wireless display adapter. According to their reports, the Microsoft Wireless Display Adapter has been sold out in the Microsoft Store in the United States, and subsequent restocking seems unlikely. The Microsoft Wireless Display Adapter is a once-popular product that easily connects Miracast-compatible devices to HDTVs or monitors, allowing users to share their tablets, laptops, or smartphones.

The new Windows 11 SDK for build 22523 revealed that Microsoft is developing a new blur effect for Windows 11. This effect is called Tabbed, and is in addition to Acrylic and Mica. The new DWMWA_SYSTEMBACKDROP_TYPE in the 22523 SDK, Mica, Acrylic’s public Win32 API and their weird new “tab” mix: pic.twitter.com/dbsu7ZFiIi — It’s All Back (@StartIsBack) December 15, 2021 Available in the following SDK’s Sample application

WPF is a desktop application development framework based on the .NET Framework developed by Microsoft. It provides rich user interface elements, data binding, animation and other functions, allowing developers to easily create high-quality desktop applications.

The WindowsAppSDK is a set of tools and APIs that developers can use in their Windows applications to provide "consistent" functionality across a variety of devices using Windows 10 (version 1809 and later) and Windows 11. It's really important to understand that it doesn't replace existing application types like .NET or Windows SDK, it just provides a unified API toolset that can be used to complement your existing applications. Today, Microsoft released version 1.2 of Windows App SDK with many new features. The highlight of this release may be third-party developers

Master the essential skills for secondary development of Java Hikvision SDK Introduction: With the rapid development of information technology, video surveillance systems have been widely used in various fields. As the leading domestic video surveillance solution provider, Hikvision’s products and technologies have always occupied an important position in the market. In order to meet the needs of different projects, Hikvision provides SDK for developers to carry out secondary development. This article will introduce some essential skills for mastering the secondary development of Java Hikvision SDK, and attach corresponding code examples. 1. Understand Hikvision

According to news from this site on February 20, after Microsoft stopped supporting Surface Pro (fifth generation) last month, it recently issued another reminder stating that it will stop supporting Surface Pro 7 on February 28, 2024 and will no longer push new firmware updates for it. Note from this site: Surface Pro 7 was released in 2019, using Intel’s 10th generation Core processor, with up to 16GB RAM and 1TB SSD options. This product supports fast charging and can last a whole day on a full charge. The official feature is the ready-to-use function, so you can continue working anytime and anywhere. The Surface Pro 7 has enjoyed regular firmware updates for nearly five years. After February 28, Microsoft will no longer push firmware updates to the device to fix specific issues related to the device.

The full name of sdk is "Software Development Kit", which means "software development kit" in Chinese. It is a set of tools provided by manufacturers of hardware platforms, operating systems (OS) or programming languages. SDKs assist software developers in creating applications for specific platforms, systems or programming languages. A basic SDK usually consists of a compiler, debugger, and application programming interface (API), but may also include other content, such as: documentation, libraries, runtime/development environment, testing/analysis tools, network protocols, etc.

