最近2018中文字幕在日韩欧美国产成人片_国产日韩精品一区二区在线_在线观看成年美女黄网色视频_国产精品一区三区五区_国产精彩刺激乱对白_看黄色黄大色黄片免费_人人超碰自拍cao_国产高清av在线_亚洲精品电影av_日韩美女尤物视频网站

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
WPF與Surface2.0SDK親密接觸–LibraryBar篇-創(chuàng)新互聯(lián)

LibraryBar 介紹

     與LibraryStack 類似LibraryBar 也屬于ItemsControl,在LibraryBar 里的組件會(huì)以水平平鋪方式展示,并且也可以對其中的組件進(jìn)行按組分類。同樣LibraryBar 也是默認(rèn)支持拖拽操作。

公司主營業(yè)務(wù):成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站建設(shè)、移動(dòng)網(wǎng)站開發(fā)等業(yè)務(wù)。幫助企業(yè)客戶真正實(shí)現(xiàn)互聯(lián)網(wǎng)宣傳,提高企業(yè)的競爭能力。創(chuàng)新互聯(lián)是一支青春激揚(yáng)、勤奮敬業(yè)、活力青春激揚(yáng)、勤奮敬業(yè)、活力澎湃、和諧高效的團(tuán)隊(duì)。公司秉承以“開放、自由、嚴(yán)謹(jǐn)、自律”為核心的企業(yè)文化,感謝他們對我們的高要求,感謝他們從不同領(lǐng)域給我們帶來的挑戰(zhàn),讓我們激情的團(tuán)隊(duì)有機(jī)會(huì)用頭腦與智慧不斷的給客戶帶來驚喜。創(chuàng)新互聯(lián)推出鳳陽免費(fèi)做網(wǎng)站回饋大家。

     下面的例子將通過LibraryBar 展示一組Sample 圖片。首先,仍然可以使用DataTemplate 作為LibraryBar 的樣式模板用來綁定圖片資源。接下來在Grid 中添加LibraryBar 控件,并設(shè)置好ItemTemplate 數(shù)據(jù)模板。我們可以通過修改Rows 參數(shù)調(diào)整LibraryBar 中組件顯示的行數(shù)。

                                                                Rows="3"
ItemTemplate="{StaticResource LibraryBarItemTemplate}"/>

     為LiraryBar 添加圖片數(shù)據(jù)源。注意,同樣不能將圖片string[] 數(shù)組直接賦給LiraryBar,需要借助ObservableCollection。

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

默認(rèn)兩行模式:

WPF 與Surface 2.0 SDK 親密接觸–LibraryBar 篇

三行模式:

WPF 與Surface 2.0 SDK 親密接觸–LibraryBar 篇

LibraryBar 分組

     接下來我們將圖片進(jìn)行分組操作,先增加一個(gè)PhotoAlbum 類,其中包含圖片的路徑、標(biāo)簽、組名信息。

class PhotoAlbum  {      private string label;      private string fileName;      private string groupName;      private BitmapImage bitmap;        public PhotoAlbum(string fileName, string label, string groupName)      {          this.fileName = fileName;          this.label = label;          this.groupName = groupName;          this.bitmap = new BitmapImage(new Uri(fileName, UriKind.Absolute));      }        public string Label      {          get { return label; }      }
public string FileName { get { return fileName; } }
public string GroupName { get { return groupName; } } public BitmapSource Bitmap { get { return bitmap; } } }

對DataTemplate 稍作修改,添加圖片標(biāo)簽

                                                                

     依據(jù)GroupName 作為分組的方式,為GroupDescriptions 默認(rèn)的集合瀏覽方式添加PropertyGroupDescription 對象,并賦給ItemsSource 屬性。

ObservableCollection items = new ObservableCollection();  string imagesPath = @"C:\Users\Public\Pictures\Sample Pictures\";    items.Add(new PhotoAlbum(imagesPath + "Hydrangeas.jpg", "Hydrangeas", "Nature"));  items.Add(new PhotoAlbum(imagesPath + "Lighthouse.jpg", "Lighthouse", "Nature"));  items.Add(new PhotoAlbum(imagesPath + "Tulips.jpg", "Tulips", "Nature"));  items.Add(new PhotoAlbum(imagesPath + "Jellyfish.jpg", "Jellyfish", "Animal"));  items.Add(new PhotoAlbum(imagesPath + "Koala.jpg", "Koala", "Animal"));  items.Add(new PhotoAlbum(imagesPath + "Penguins.jpg", "Penguins", "Animal"));    mLibraryBar.ItemsSource = items;  ICollectionView defaultView = CollectionViewSource.GetDefaultView(items);  defaultView.GroupDescriptions.Add(new PropertyGroupDescription("GroupName"));

WPF 與Surface 2.0 SDK 親密接觸–LibraryBar 篇

LibraryBar 拖拽

     從上面的示例中可以發(fā)現(xiàn),我們無法將圖片從LibraryBar 中拖拽出來,當(dāng)拖拽操作結(jié)束后圖片會(huì)自動(dòng)返回到LibraryBar。接下來將實(shí)現(xiàn)把圖片拖拽到ScatterView 控件。

     首先,對XAML 控件進(jìn)行下修改,將LibraryBar 放入ScatterView 控件。這里需要將ScatterView 的AllwoDrop 屬性設(shè)為True,背景也要填充顏色,可設(shè)置為Transparent 透明,這樣才能保證LibraryBar 中的組件可以拖拽到ScatterView 中。

                                                

     其次,為ScatterView 添加SurfaceDragDrop.Drop 事件用于處理拖拽的操作。在事件觸發(fā)時(shí),新建一個(gè)ScatterViewItem(newItem) 用于裝載被拖動(dòng)的圖片組件。將e.Cursor.Data 轉(zhuǎn)化為PhotoAlbum,借助FileName 屬性新建MediaElement。將MediaElement(mediaItem)賦給newItem.Content,并通過GetPosition 獲取到拖拽動(dòng)作的位置作為newItem 在ScatterView 中的顯示位置。

private void scatterView_Drop(object sender, SurfaceDragDropEventArgs e)  {      PhotoAlbum data = e.Cursor.Data as PhotoAlbum;            ScatterViewItem newItem = new ScatterViewItem();      MediaElement mediaItem = new MediaElement();      mediaItem.Source = new Uri(data.FileName);      newItem.Background = Brushes.Transparent;      newItem.Content = mediaItem;      newItem.Center = e.Cursor.GetPosition(scatterView);            scatterView.Items.Add(newItem);  }

     這樣我們就實(shí)現(xiàn)了將LibraryBar 中的組件拖拽到ScatterView。MSDN 上也提供了文檔供大家參考:Using the Microsoft Surface Drag-and-Drop Framework

WPF 與Surface 2.0 SDK 親密接觸–LibraryBar 篇

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。


本文標(biāo)題:WPF與Surface2.0SDK親密接觸–LibraryBar篇-創(chuàng)新互聯(lián)
網(wǎng)址分享:http://fisionsoft.com.cn/article/digogs.html