> 데이터 베이스 > MySQL 튜토리얼 > WPF 与Surface 2.0 SDK 亲密接触–LibraryContainer 篇

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

WBOY
풀어 주다: 2016-06-07 15:20:04
원래의
1216명이 탐색했습니다.

最近比较懒惰一直都没写东西,再不写笔里的墨水就快干了。看过前面关于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>
로그인 후 복사

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>));
로그인 후 복사

运行效果:

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/)

관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿