WPF中的ListBox實(shí)現(xiàn)按塊顯示元素的方法
本文實(shí)例講述了WPF中的ListBox實(shí)現(xiàn)按塊顯示元素的方法。分享給大家供大家參考,具體如下:
注意:需要設(shè)置ListBox的屬性 ScrollViewer.HorizontalScrollBarVisibility="Disabled"
關(guān)鍵代碼,WPF中有內(nèi)置的WrapPanel控件,在ListBox.ItemsPanel中使用可以讓元素按塊顯示
<ListBox.ItemsPanel> <ItemsPanelTemplate> <WrapPanel/> </ItemsPanelTemplate> </ListBox.ItemsPanel>
<ListBox Height="304" HorizontalAlignment="Left" Margin="14,143,0,0" Name="lstTables" VerticalAlignment="Top" Width="615" ScrollViewer.HorizontalScrollBarVisibility="Disabled" > <ListBox.ItemsPanel> <ItemsPanelTemplate> <WrapPanel/> </ItemsPanelTemplate> </ListBox.ItemsPanel> <ListBox.ItemTemplate> <DataTemplate> <Grid Margin="20,20,20,20"> <Grid.RowDefinitions> <RowDefinition></RowDefinition> <RowDefinition></RowDefinition> <RowDefinition></RowDefinition> </Grid.RowDefinitions> <Image Source="Images/table.png" Grid.Row="0" Height="42" Width="42" HorizontalAlignment="Center"> <Image.Effect> <DropShadowEffect/> </Image.Effect> </Image> <TextBlock Text="{Binding FTableName,Mode=TwoWay}" Grid.Row="1" HorizontalAlignment="Center" Margin="5,5,5,5" /> <CheckBox IsChecked="{Binding FSelected,Mode=TwoWay,Converter={StaticResource SelCTS}}" Grid.Row="2" HorizontalAlignment="Center"> <CheckBox.Effect> <DropShadowEffect/> </CheckBox.Effect> </CheckBox> </Grid> </DataTemplate> </ListBox.ItemTemplate> </ListBox>
更多關(guān)于C#相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《C#窗體操作技巧匯總》、《C#常見控件用法教程》、《WinForm控件用法總結(jié)》、《C#程序設(shè)計(jì)之線程使用技巧總結(jié)》、《C#操作Excel技巧總結(jié)》、《C#中XML文件操作技巧匯總》、《C#數(shù)據(jù)結(jié)構(gòu)與算法教程》、《C#數(shù)組操作技巧總結(jié)》及《C#面向?qū)ο蟪绦蛟O(shè)計(jì)入門教程》
希望本文所述對大家C#程序設(shè)計(jì)有所幫助。
相關(guān)文章
c# StringBuilder.Replace 方法 (Char, Char, Int32, Int32)
c# StringBuilder.Replace 方法 (Char, Char, Int32, Int32)...2007-08-08C#使用CallContext緩存線程數(shù)據(jù)
這篇文章介紹了C#使用CallContext緩存線程數(shù)據(jù)的方法,文中通過示例代碼介紹的非常詳細(xì)。對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-05-05unity實(shí)現(xiàn)手機(jī)端搖桿控制人物移動(dòng)
這篇文章主要為大家詳細(xì)介紹了unity實(shí)現(xiàn)手機(jī)端搖桿控制人物移動(dòng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-04-04c#使用windows服務(wù)更新站點(diǎn)地圖的詳細(xì)示例
這篇文章主要介紹了c#使用windows服務(wù)更新站點(diǎn)地圖的詳細(xì)示例,需要的朋友可以參考下2014-04-04.net實(shí)現(xiàn)序列化與反序列化實(shí)例解析
這篇文章主要介紹了.net實(shí)現(xiàn)序列化與反序列化實(shí)例解析,需要的朋友可以參考下2014-08-08