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

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

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

最近比较懒惰一直都没写东西,再不写笔里的墨水就快干了。看过前面关于LibraryStack 和LibraryBar 的介绍后,大家可能已经对Library 控件系列有了进一步了解,本篇将继续介绍LibraryContainer,它其实就是LibraryStack、LibrayBar 的集合体。 首先,我们仍然

最近比较懒惰一直都没写东西,再不写笔里的墨水就快干了。看过前面关于LibraryStack 和LibraryBar 的介绍后,大家可能已经对Library 控件系列有了进一步了解,本篇将继续介绍LibraryContainer,它其实就是LibraryStack、LibrayBar 的集合体。

     首先,我们仍然需要创建一个DataTemplate 用来控制LibraryStack、LibrayBar 的显示样式。然后新建一个LibraryContainer,在其中增加StackView 和BarView 两种浏览模式。

<span><span>s</span><span>:</span><span>SurfaceWindow.Resources</span><span>>
    <span>DataTemplate </span><span>x</span><span>:</span><span>Key</span><span>="LibraryBarItemTemplate">
        <span>Grid </span><span>>
            <span>Image </span><span>Source</span><span>="{</span><span>Binding </span><span>Bitmap</span><span>}"/>
            <span>Label </span><span>FontSize</span><span>="14" </span><span>Content</span><span>="{</span><span>Binding </span><span>Label</span><span>}"/>
        </span><span>Grid</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>LibraryContainer </span><span>x</span><span>:</span><span>Name</span><span>="mlibraryContainer">
        <span>s</span><span>:</span><span>LibraryContainer.StackView</span><span>>
            <span>s</span><span>:</span><span>StackView </span><span>ItemTemplate</span><span>="{</span><span>StaticResource </span><span>LibraryBarItemTemplate</span><span>}"/>
        </span><span>s</span><span>:</span><span>LibraryContainer.StackView</span><span>>

        <span>s</span><span>:</span><span>LibraryContainer.BarView</span><span>>
            <span>s</span><span>:</span><span>BarView </span><span>ItemTemplate</span><span>="{</span><span>StaticResource </span><span>LibraryBarItemTemplate</span><span>}"/>
        </span><span>s</span><span>:</span><span>LibraryContainer.BarView</span><span>>
    </span><span>s</span><span>:</span><span>LibraryContainer</span><span>>
</span><span>Grid</span><span>>
</span></span></span></span></span></span></span></span></span></span></span></span>
Copy after login

LibraryBar 一样我们继续使用分组的浏览模式,按GroupName 进行分组操作,PhotoAlbum 类请参考这里。

<span>ObservableCollection</span>PhotoAlbum> items = <span>new </span><span>ObservableCollection</span>PhotoAlbum>();
<span>string </span>imagesPath = <span>@"C:\Users\Public\Pictures\Sample Pictures\"</span>;

items.Add(<span>new </span><span>PhotoAlbum</span>(imagesPath + <span>"Hydrangeas.jpg"</span>, <span>"Hydrangeas"</span>, <span>"Nature"</span>));
items.Add(<span>new </span><span>PhotoAlbum</span>(imagesPath + <span>"Lighthouse.jpg"</span>, <span>"Lighthouse"</span>, <span>"Nature"</span>));
items.Add(<span>new </span><span>PhotoAlbum</span>(imagesPath + <span>"Tulips.jpg"</span>, <span>"Tulips"</span>, <span>"Nature"</span>));
items.Add(<span>new </span><span>PhotoAlbum</span>(imagesPath + <span>"Jellyfish.jpg"</span>, <span>"Jellyfish"</span>, <span>"Animal"</span>));
items.Add(<span>new </span><span>PhotoAlbum</span>(imagesPath + <span>"Koala.jpg"</span>, <span>"Koala"</span>, <span>"Animal"</span>));
items.Add(<span>new </span><span>PhotoAlbum</span>(imagesPath + <span>"Penguins.jpg"</span>, <span>"Penguins"</span>, <span>"Animal"</span>));

mlibraryContainer.ItemsSource = items;
<span>ICollectionView </span>defaultView = <span>CollectionViewSource</span>.GetDefaultView(items);
defaultView.GroupDescriptions.Add(<span>new </span><span>PropertyGroupDescription</span>(<span>"GroupName"</span>));
Copy after login

运行效果:

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

按分组选择:

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

点击下方按钮切换为BarView 模式:

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

作者:李敬然(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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 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)

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

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.

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.

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.

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

Installation and use of WeChat mini program PHP SDK Installation and use of WeChat mini program PHP SDK Mar 27, 2024 am 09:33 AM

Installation and use of WeChat Mini Program PHPSDK With the rapid development of the mobile Internet, WeChat Mini Program has become a new way for more and more companies to conduct business and promote products. WeChat Mini Program PHPSDK provides developers with convenient and fast development tools, which can greatly improve development efficiency. This article will introduce the installation and use of WeChat applet PHPSDK. 1. Install SDK 1. Download the project file on GitHub. WeChat applet PHPSDK is an open source project. Developers can download it on GitHub.

See all articles