相关疑难解决方法(0)

WPF ListView与项目的水平排列?

我想以类似于列表模式下的WinForms ListView的方式在ListView中布置项目.也就是说,在ListView中不仅在垂直方向而且在水平方向上布置项目.

我不介意这些物品的布局是这样的:

1 4 7
2 5 8
3 6 9

或者像这样:

1 2 3
4 5 6
7 8 9

只要它们在垂直和水平方向呈现,以便最大限度地利用可用空间.

我能找到的最接近的是这个问题:

如何使WPF ListView项目水平重复,如水平滚动条?

只能水平放置项目.

wpf layout listview

55
推荐指数
3
解决办法
7万
查看次数

使用数据绑定在WPF MVVM中以ListView(或更好的东西!)显示图像

我试图在ListView中显示一些图像,但没有成功.我正在使用WPF MVVM,而ListView是简单地显示套装和排名数据的延续.(请参阅我之前的帖子:WPF中的MVVM - 如何提醒ViewModel模型中的更改......或者我应该?如果您感兴趣的话!)也就是说,我可以使用ListView以外的东西(如果这是建议)但我仍然想知道如何使用ListView,假设它是可行的.我在ViewModel中绑定的属性是:

public ObservableCollection<Image> PlayerCardImages{
    get{
        ObservableCollection<Image> results = new ObservableCollection<Image>();
        foreach (CardModel card in PlayerCards)
        {
            Image img = new Image();
            BitmapImage bi3 = new BitmapImage();
            bi3.BeginInit();
            // TODO: Pick card based on suit/rank. Just get  1 image working now
            bi3.UriSource = new Uri("diamond-1.png", UriKind.Relative);
            bi3.EndInit();
            img.Stretch = Stretch.Fill;
            img.Source = bi3;            
            results.Add(img);
        }
        return results;
    }
}
Run Code Online (Sandbox Code Playgroud)

在我使用的XAML代码中:

<Window.Resources>
 <DataTemplate x:Key="ImageCell">
        <StackPanel Orientation="Horizontal">
            <Image Source="{Binding PlayerCardImages}" Width="200" Height="200" Stretch="Fill" ToolTip="Add tooltip"/>
        </StackPanel> …
Run Code Online (Sandbox Code Playgroud)

c# wpf listview image mvvm

8
推荐指数
1
解决办法
3万
查看次数

在WPF ListView中将项目显示为图像

所以我一个绑定ListListView,其中List有一个类型的项目Album,它有很多特性,包括.Cover,我是在磁盘上的图像.好吧,因为我不知道需要什么类型的图像以及如何加载它们(我只知道使用Winforms的图像类型),我还不知道它的类型.

有人可以展示或发布一个快速样本,其中显示这类项目使用其.Cover属性显示为某个固定大小的图像?

实质上,这将显示:

  1. .Cover应该是什么类型
  2. 如何从磁盘打开WPF图像(假设它与Winforms图像加载不同)
  3. 如何在ListView上将它们显示为特定固定大小的图像,必要时缩放图像

.net c# wpf listview image

1
推荐指数
1
解决办法
2万
查看次数

标签 统计

listview ×3

wpf ×3

c# ×2

image ×2

.net ×1

layout ×1

mvvm ×1