久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

silverlight教程(5)——使用列表,,并和數(shù)據(jù)綁定,,以顯示列表數(shù)據(jù)

 莣ヤㄋ莪 2009-05-07
以前我們一直在用DataGrid控件,以顯示我們的digg故事,,這個工程很大,,當(dāng)我們要展示的內(nèi)容,在一欄格式為我們的digg申請,,雖然,,我們可能要調(diào)整出現(xiàn)多一點,有它少看像一個在DataGrid的故事,,而更像是名單當(dāng)中,。好消息是,這很容易-它不要求我們改變我們的任何應(yīng)用程序代碼,,以完成這項工作,。

We'll start by replacing our DataGrid control with a <ListBox> control.  We'll keep the control name the same as before ("StoriesList"):我們也將開始取代我們的DataGrid控件與<listbox>控制,我們將繼續(xù)控制名字一樣( " storieslist " ) :

When we run our application again and search for stories, the ListBox will display the following results:當(dāng)我們來說,,我們的應(yīng)用程序,,再尋找的故事,列表將顯示下列結(jié)果:

You might be wondering - why is each item "DiggSample.DiggStory"?  The reason for this is because we are binding DiggStory objects to the ListBox (and the default behavior is to call ToString() on them).  If we want to display the "Title" property of the DiggStory object instead, we can set the "DisplayMemberPath" property on the ListBox:你可能不知道-為什么每個項目的" d iggsample.diggstory" ,?究其原因,,是因為我們雙方都具有約束力, d iggstory物體向列表(及違約行為是呼吁t ostring( ) ,,對他們的) ,,但如果我們想要展示"標(biāo)題"財產(chǎn)的安全diggstory對象相反,,我們可以設(shè)置" displaymemberpath "財產(chǎn)上的列表框:

When we do this the Title will be what is displayed in the ListBox:當(dāng)我們這樣做標(biāo)題,將是什么顯示在列表:

If we want to show more than one value at a time, or customize the layout of each item more, we can override the ListBox control's ItemTemplate and supply a custom DataTemplate.如果我們想表達(dá)一個以上的價值,,在一個時間,,或個性化布局的每一個項目,我們更可以凌駕列表控制的itemtemplate和供應(yīng)定制datatemplate ,。 Within this DataTemplate we can customize how each DiggStory object is displayed.在這個datatemplate我們可以定制如何使每個diggstory對象顯示出來,。

For example, we could display both the DiggStory Title and NumDiggs value using a DataTemplate like below.舉例來說,我們可以顯示兩diggstory標(biāo)題和numdiggs價值用datatemplate像下面,。

We can databind any public properties we want from our DiggStory object within the DataTemplate.  Notice above how we are using the {Binding PropertyName } syntax to accomplish this with the two TextBlock controls.我們可以databind任何公共財產(chǎn),,我們希望從我們的diggstory物體內(nèi)部datatemplate 。預(yù)告以上我們?nèi)绾问褂茫s束力propertyname )語法要做到這一點,,與兩個textblock管制,。

With the above DataTemplate in place, our ListBox will now display its items like below:符合上述datatemplate到位,我們將列表框,,現(xiàn)在展現(xiàn)自己的項目,,例如如下:

Let's then go one step further and change our DataTemplate to the one below.  This DataTemplate uses two StackPanels - one to stack row items horizontally, and one to stack some textblocks together vertically:讓的,然后走一步,,進(jìn)一步轉(zhuǎn)變我們的datatemplate ,,將其中的下面,這datatemplate使用兩個stackpanels -一至棧連續(xù)橫向項目,,其中以堆疊一些t extblocks一道縱向:

The above DataTemplate causes our ListBox to display items like the screen-shot below:上述datatemplate使我們的列表中顯示的項目,如在屏幕上拍攝如下:

when we define the following Style rules in our App.xaml (note how we are using a LinearGradientBrush to get the nice yellow gradient background on the DiggPanel):當(dāng)我們確定了以下規(guī)則作風(fēng),,在我們的app.xaml (注如何,,我們用的是lineargradientbrush得到尼斯黃色梯度背景就diggpanel ) :

One important thing to notice about our ListBox - even though we have customized what the items in it look like, it still automatically provides support for hover and item selection semantics.  This is true both when using the mouse and when using the keyboard (up/down arrow keys, home/end, etc):其中重要一點,以通知我們列表-即使我們定制的是什么項目,,它看起來像,,它仍然會自動提供支持懸停和項目選擇的語義,這才是真正的既當(dāng)使用鼠標(biāo)時,,使用快捷鍵( /向下箭頭鍵,,主頁/結(jié)束等) :

The ListBox also supports full flow resizing - and will provide automatic scrolling of our custom content when necessary (notice how the horizontal scroll bar appears as the window gets smaller):該列表還支持全流量大小-并會自動提供滾動的定制內(nèi)容,必要時(預(yù)告如何橫向卷軸似乎為窗口減?。?:

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點,。請注意甄別內(nèi)容中的聯(lián)系方式,、誘導(dǎo)購買等信息,謹(jǐn)防詐騙,。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,,請點擊一鍵舉報,。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多