WPF图库 [英] WPF Image Gallery

查看:136
本文介绍了WPF图库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将推动需要向用户展示图像组的触摸屏应用程序(不是Web应用程序)。希望呈现具有页面前向/后向能力的3×3网格图像。他们可以选择一些,我只会展示这些图片。

I'm going to be driving a touch-screen application (not a web app) that needs to present groups of images to users. The desire is to present a 3x3 grid of images with a page forward/backward capability. They can select a few and I'll present just those images.

我没有看到 ListView 我想要的是什么(虽然WPF足够大,我可能错过了一些明显的东西!)。我可以设置 Grid 并将图像填入网格位置。但我希望有更好,更自动化,更少暴力的东西。有什么想法或指示吗?

I don't see that ListView does quite what I want (although WPF is big enough that I might well have missed something obvious!). I could set up a Grid and stuff images in the grid positions. But I was hoping for something nicer, more automated, less brute-force. Any thoughts or pointers?

推荐答案

您可能想要使用 ItemsControl / ListBox 然后为3x3显示设置一个 UniformGrid 面板作为其 ItemsPanel 实现正确的WPF可绑定解决方案。

You might want to use an ItemsControl/ListBox and then set a UniformGrid panel for a 3x3 display as its ItemsPanel to achieve a proper WPF bindable solution.

 <ListBox ScrollViewer.HorizontalScrollBarVisibility="Disabled">
    <ListBox.ItemsPanel>
      <ItemsPanelTemplate>
        <UniformGrid Rows="3" Columns="3"/>
       </ItemsPanelTemplate>
    </ListBox.ItemsPanel>
  <Image Source="Images\img1.jpg" Width="100"/>
  <Image Source="Images\img2.jpg" Width="50"/>
  <Image Source="Images\img3.jpg" Width="200"/>
  <Image Source="Images\img4.jpg" Width="75"/>
  <Image Source="Images\img5.jpg" Width="125"/>
  <Image Source="Images\img6.jpg" Width="100"/>
  <Image Source="Images\img7.jpg" Width="50"/>
  <Image Source="Images\img8.jpg" Width="50"/>
  <Image Source="Images\img9.jpg" Width="50"/>
 </ListBox>

如果您在此处寻找动态解决方案,则需要将Images的集合设置为ItemsSource绑定。但问题太宽泛,无法给出确切答案。

You need to set your collection of Images as ItemsSource binding if you are looking for a dynamic solution here. But the question is too broad to give an exact answer.

这篇关于WPF图库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆