[英]How to customize LongListSelector or ListBox Design in WP8
我喜歡以自己的方式自定義我的LongListSelector或ListBox,所以任何人都可以幫助我進行設計。
我的代碼..
<StackPanel HorizontalAlignment="Left" Height="345" Margin="10,234,0,0" VerticalAlignment="Top" Width="413">
<phone:LongListSelector x:Name="list_organization" Height="340" Margin="10,0"/>
</StackPanel>
這是我綁定長列表的代碼。
org = await client.searchOrganization(txtQuery.Text);
if (org != null)
{
var query = from c in org
select new { c.name,c.id,c.time,.. };
list_organization.ItemsSource = query.ToList();//bind the query to longlist
}
我想要這個設計頁面。
怎么做...?
首先,刪除明確的寬度和高度。 而且,如果在StackPanel
只有一個LongListSelector
,則可以刪除StackPanel
。
通過使用DataTemplate
替換ItemTemplate
可以完成類似於列表框的容器的各個項目。 檢查以下MSDN鏈接以獲取更多信息: ListBox樣式和模板 。
基本上,這是您的操作方法:
<phone:LongListSelector x:Name="list_organization" Height="340" Margin="10,0"
ItemsSource="{Binding People}">
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<!-- your XAML for individual item goes here -->
<TextBlock Text="{Binding FirstName}" />
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.