Home Database Mysql Tutorial WPF 与Surface 2.0 SDK 亲密接触–LibraryStack 篇

WPF 与Surface 2.0 SDK 亲密接触–LibraryStack 篇

Jun 07, 2016 pm 03:20 PM
sdk surface wpf

LibraryStack 本身属于ItemsControl,可以将其他组件以一种集合的方式显示出来,用户可以在LibraryStack 中逐一浏览如图片类的组件,而且它默认支持拖拽操作。 在下面的例子中我们将通过LibraryStack 展示一组图片。首先,为LibraryStack 编写一个DataTemplat

LibraryStack 本身属于ItemsControl,可以将其他组件以一种集合的方式显示出来,用户可以在LibraryStack 中逐一浏览如图片类的组件,而且它默认支持拖拽操作。

     在下面的例子中我们将通过LibraryStack 展示一组图片。首先,为LibraryStack 编写一个DataTemplate 用来绑定图片样式。接下来在Grid 中添加LibraryStack 控件,并设置好数据模板。

<span><span>s</span><span>:</span><span>SurfaceWindow </span><span>x</span><span>:</span><span>Class</span><span>="Demo.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>="LibraryStack"
>
    <span>s</span><span>:</span><span>SurfaceWindow.Resources</span><span>>
        <span>DataTemplate </span><span>x</span><span>:</span><span>Key</span><span>="ItemTemplate">
            <span>Image </span><span>Source</span><span>="{</span><span>Binding</span><span>}"/>
        </span><span>DataTemplate</span><span>>
    </span><span>s</span><span>:</span><span>SurfaceWindow.Resources</span><span>>

    <span>Grid</span><span>>
        <span>s</span><span>:</span><span>LibraryStack </span><span>x:Name</span><span>="mLibraryStack" 
                        </span><span>ItemTemplate</span><span>="{</span><span>StaticResource </span><span>ItemTemplate</span><span>}"/>
    </span><span>Grid</span><span>>
</span><span>s</span><span>:</span><span>SurfaceWindow</span><span>>
</span></span></span></span></span></span></span>
Copy after login

     最后,为LiraryStack 添加数据源。注意,不能将图片string[] 数组直接赋给LiraryStack,需要借助ObservableCollection。

<span>string </span>imagesPath = <span>@"C:\Users\Public\Pictures\Sample Pictures\"</span>;
<span>try
</span>{
    <span>string</span>[] files = System.IO.<span>Directory</span>.GetFiles(imagesPath, <span>"*.jpg"</span>);
    <span>ObservableCollection</span>string> items = <span>new </span><span>ObservableCollection</span>string>(files);
    mLibraryStack.ItemsSource = items;
}
<span>catch </span>(System.IO.<span>DirectoryNotFoundException</span>)
{
    <span>// Error info.
</span>}
Copy after login

运行界面:

WPF 与Surface 2.0 SDK 亲密接触–LibraryStack 篇

作者:李敬然(Gnie)
出处:{GnieTech} (http://www.cnblogs.com/gnielee/)

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1269
29
C# Tutorial
1248
24
Microsoft's Wireless Display Adapter is discontinued: Can Surface take up the slack? Microsoft's Wireless Display Adapter is discontinued: Can Surface take up the slack? Sep 08, 2023 pm 03:53 PM

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.

Microsoft is developing new blur effects for Windows 11 Microsoft is developing new blur effects for Windows 11 May 13, 2023 am 09:04 AM

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

Master the essential skills for secondary development of Java Hikvision SDK Master the essential skills for secondary development of Java Hikvision SDK Sep 06, 2023 am 08:10 AM

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

WPF tutorial from entry to proficiency WPF tutorial from entry to proficiency Oct 27, 2023 am 09:45 AM

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.

No need to enter a password, Microsoft Surface Pro 10 Business Edition has a built-in NFC card reader: swipe the security key to log in No need to enter a password, Microsoft Surface Pro 10 Business Edition has a built-in NFC card reader: swipe the security key to log in Mar 23, 2024 pm 03:41 PM

According to news from this site on March 23, Microsoft recently released the commercial version of Surface Pro 10. The starting price in China is 9888 yuan. One of its highlights is the built-in NFC card reader. Users no longer need to enter passwords and can directly use hardware security such as YubiKey. Key login, verify user identity. The Surface Pro 10 commercial version has an NFC card reader embedded in the upper left corner of the computer screen. Currently, Microsoft has cooperated with Yubico to use YubiKey hardware for authentication, and will further expand more supported brands and products in the future. According to a joint announcement from Microsoft and Yubico, Surface Pro 10 commercial version users only need to place the YubiKey in the upper left corner of the screen to log in.

what is sdk what is sdk Jan 06, 2023 pm 03:26 PM

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.

Reaching the end of five years of firmware updates, Microsoft ends support for Surface Pro 7 2-in-1 laptop this month Reaching the end of five years of firmware updates, Microsoft ends support for Surface Pro 7 2-in-1 laptop this month Feb 20, 2024 pm 02:27 PM

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.

Windows App SDK 1.2 is now online, here's what's new Windows App SDK 1.2 is now online, here's what's new May 12, 2023 pm 06:07 PM

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

See all articles