0
我在我的WPF应用程序定义了以下列表框:滚动在列表框鼠标滚轮与修改ItemsPanel
<ListBox DockPanel.Dock="Bottom" Height="105" Name="ThumbnailsList" Background="#80FFFFF0"
SelectionChanged="ThumbnailsList_SelectionChanged">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
我想改变ItemsPanel使用VirtualizingStackPanel性能和改变列表框的方向(部分注释掉) - ListBoxItems是缩略图图像。但是,这会导致我无法使用鼠标滚轮滚动列表框项目。
是否有任何解决方案来保持此自定义,但有鼠标滚动功能?
由于提问者叶兰,添加项目的代码如下:
foreach (string filename in Images)
{
Image img = new Image();
BitmapImage bmp = new BitmapImage();
try
{
using (FileStream stream = File.OpenRead(filename))
{
bmp.BeginInit();
bmp.CacheOption = BitmapCacheOption.OnLoad;
bmp.DecodePixelHeight = 75;
bmp.StreamSource = stream;
bmp.EndInit();
}
}
catch (Exception ex)
{
//commented out
}
Border b = new Border();
b.BorderBrush = Brushes.AntiqueWhite;
b.BorderThickness = new Thickness(1);
b.Child = img;
b.Effect = ef; //this is System.Windows.Media.Effects.DropShadowEffect
img.SnapsToDevicePixels = true;
img.Source = bmp;
img.Height = 75;
img.ToolTip = filename.Substring(lastSlash + 1);
ThumbnailsList.Items.Add(b);
}
发布listboxitem – 2014-09-02 18:35:55