如何制作可滚动的垂直网格图像
问题描述:
我需要制作可沿着垂直轴进行滚动的图像列表。如何制作可滚动的垂直网格图像
图片链接在string[] imagesLocation
。
当点击图块时,事件处理程序应该知道string imageLocation
。
它建议立即进行删除是这个样子:
我能够使其在网格中。但无法使其滚动。
发现一些小费使用LongListSelector
,但无法使其工作。
更新:
MainPage.xaml.cs中:
namespace PhoneApp1
{
public partial class MainPage : PhoneApplicationPage
{
public MainPage()
{
InitializeComponent();
ContentPanel.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
ContentPanel.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength() });
ContentPanel.RowDefinitions.Add(new RowDefinition() { Height = new GridLength() });
ContentPanel.Children.Add(new TextBlock() { });
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 5; j++)
{
Image MyImage1 = new Image();
MyImage1.SetValue(Grid.ColumnProperty, i);
MyImage1.SetValue(Grid.RowProperty, j);
ImageSource src = new BitmapImage(new Uri(string.Format("Assets/ApplicationIcon.png"), UriKind.RelativeOrAbsolute));
MyImage1.Source = src;
ContentPanel.Children.Add(MyImage1);
}
}
}
}
}
MailPage.xaml:
<phone:PhoneApplicationPage
x:Class="PhoneApp1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0"/>
<TextBlock Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<Grid Grid.Row="1" x:Name="ContentPanel">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="160"></ColumnDefinition>
<ColumnDefinition Width="160"></ColumnDefinition>
<ColumnDefinition Width="160"></ColumnDefinition>
</Grid.ColumnDefinitions>
</Grid>
</Grid>
</phone:PhoneApplicationPage>
答
我想到了一个简单的解决办法的,你可以尝试。 插入Panel
,然后再创建内部panel
的panel
电网有一个叫做财产AutoScroll
你只需要到设置为True
panel.AutoScroll = "True";
WrapPanel
是伟大的,在垂直或铺设东西水平方向,直到到达容器的边缘,然后移动到下一列或行。但不幸的是,我发现WrapPanel
已不再受Windows应用商店应用(通用应用)的支持。
UniversalWrapPanel
是WrapPanel
布局的替代方案。
这是考虑你在Visual Studio
要获得UniversalWrapPanel
工作,去包管理器,查找和安装包UniversalWrapPanel
这将在您添加引用的DLL。
然后打开MainPage.xaml
和命名空间添加到XAML:
xmlns:UniversalWrapPanel="using:Gregstoll"
您是否尝试过gridview的? – Archana