在Windows Phone 7.5中使用Silverlight创建照片库 [英] Creating Photo Gallery with Silverlight in Windows Phone 7.5

查看:64
本文介绍了在Windows Phone 7.5中使用Silverlight创建照片库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望创建一个具有照片库的应用程序,该应用程序与内置的照片库/照片集线器几乎完全相同.

I'm looking to create an app that features a photo gallery, one that is almost exactly the same as the built in photo gallery/photos hub.

我已经看过使用网格,但是无法将数据绑定到网格.我还研究了使用DataGrid,但Windows Phone SDK中未包含该数据网格.我需要的网格将具有固定的列数,但行数将可变(就像我说的那样,就像当前内置的照片库一样)

I've looked at using a Grid, but I can't bind data to it. I also looked at using a DataGrid, but that is not included in the Windows Phone SDK. The grid I need will have a set number of columns but a variable number of rows (like I said, just like the current built in photo gallery)

有人有什么建议/解决方案吗?

Does anyone have any suggestions/solutions?

推荐答案

它将与列表框一起使用,但是您必须编辑其ItemsPanelTemplate并使用工具箱中的WrapPanel控件(水平方向)之类的东西.然后,您可以将ItemTemplate定义为正方形图像.这样,每个新项目都将堆叠在另一个项目的右边,直到没有更多空间为止,它将继续在下一行中.因此,对于一定数量的列,您必须在项目模板中指定宽度(在我的示例中为173,因此在纵向模式下,我以2列结尾).

It will work with a listbox, but you have to edit its ItemsPanelTemplate and use something like the WrapPanel control (horizontal orientation) from the toolkit. Then, you can define the ItemTemplate as a square image. That way every new item will stack at the right from the other until there's no more room and it will continue on the next row. So for a set number of columns, you have to specify the width in the item template (173 in my example so in the portrait mode, i end with 2 columns).

这是我的一个项目的示例(您应根据情况调整绑定和名称):

Here's a example from one of my projects (you should adjust bindings and names to your scenario):

<ListBox x:Name="lbxCategorias" ItemsSource="{Binding ChannelButtons}"  
                         SelectionChanged="lbxCategorias_SelectionChanged">
                <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <toolkit:WrapPanel Orientation="Horizontal" />
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Image Source="{Binding BigButtonIconPath}" Width="173" Height="173" Margin="0 0 12 10" />
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>

这篇关于在Windows Phone 7.5中使用Silverlight创建照片库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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