大家好,又见面了,我是你们的朋友全栈君。
listbox大家都会用,如果要让它支持换行操作还必须加上 ListBox.ItemsPanel ItemsPanelTemplate toolkit:WrapPanel/ /ItemsPanelTemplate /ListBox.ItemsPanel 但是也有问题了,必须设置WrapPanel的宽度,也就是不能自适应宽度去调整每一行的宽度,这样的后果可能会出现要么全部推在一起,要么要有横向的滚动条
listbox大家都会用,如果要让它支持换行操作还必须加上
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel ></WrapPanel>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
WrapPanel
是也有问题了,必须设置WrapPanel的宽度,也就是不能自适应宽度去调整每一行的宽度,这样的后果可能会出现要么全部推在一起,要么要有横向的滚动条。
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Height="150" Width="100" Orientation="Vertical" VerticalAlignment="Center">
<controls:ImageButton Width="90" Height="135" ToolTip="{Binding Name}"
NormalImage="{StaticResource ConfigSurveyManageNormalImage}"/>
<TextBlock Height="15" ToolTip="{Binding Name}" HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Binding Name}" Tag="{Binding AlarmState}"></TextBlock>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
listbox属性设置:
ListBox Grid.Row=”1″ ScrollViewer.HorizontalScrollBarVisibility=”Disabled” Name=”LBoxVaultList” VerticalAlignment=”Top” BorderThickness=”0″
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/163339.html原文链接:https://javaforall.cn