2017-04-03 56 views
0

我需要製作可沿着垂直軸進行滾動的圖像列表。如何製作可滾動的垂直網格圖像

圖片鏈接在string[] imagesLocation

當點擊圖塊時,事件處理程序應該知道string imageLocation

它建議立即進行刪除是這個樣子:

enter image description here

我能夠使其在網格中。但無法使其滾動。

發現一些小費使用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> 
+0

您是否嘗試過gridview的? – Archana

回答

0

我想到了一個簡單的解決辦法的,你可以嘗試。 插入Panel,然後再創建內部panel

panel電網有一個叫做財產AutoScroll你只需要到設置爲True

panel.AutoScroll = "True"; 

WrapPanel是偉大的,在垂直或鋪設東西水平方向,直到到達容器的邊緣,然後移動到下一列或行。但不幸的是,我發現WrapPanel已不再受Windows應用商店應用(通用應用)的支持。

UniversalWrapPanelWrapPanel佈局的替代方案。

這是考慮你在Visual Studio

要獲得UniversalWrapPanel工作,去包管理器,查找和安裝包UniversalWrapPanel這將在您添加引用的DLL。

然後打開MainPage.xaml和命名空間添加到XAML:

xmlns:UniversalWrapPanel="using:Gregstoll" 
+0

無法插入'Panel':'面板是抽象的,必須包含隱式值' – Qeeet

+0

@Qeeet嘗試更新。 –

+0

無法使其工作。首先我嘗試了'WrapPanel',安裝了WPToolKit。其次是'UniversalWrapPanel',不能從金塊安裝包,包不包含v8.1的程序集 – Qeeet