2017-04-03 17 views
0

垂直軸に沿ってスクロール可能な画像のリストを作成する必要があります。画像のスクロール可能な垂直グリッドの作成方法

画像のリンクはstring[] imagesLocationです。

タイルをクリックすると、イベントハンドラはstring imageLocationを知る必要があります。

それは次のようになりshoul:

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

私はあなたが試みることができる簡単な解決策を考え。 panelPanel最初にしてpanel内のグリッドを作成

を挿入AutoScrollあなただけTrue

panel.AutoScroll = "True"; 

WrapPanelにそれを設定する必要がありますというプロパティは、垂直またはで物事をレイアウトするのに最適ですありコンテナの端に達するまで水平方向に移動し、次の列または行に移動します。しかし、残念ながらWrapPanelはWindowsストアアプリ(Universal Apps)ではサポートされなくなりました。

UniversalWrapPanelは、WrapPanelレイアウトの代替手段です。

これは、あなたがUniversalWrapPanelを取得するにはVisual Studio

で作業している検討している、これはあなたの参考文献にDLLを追加します、パッケージマネージャに行く見つけ、パッケージUniversalWrapPanelインストールします。

その後MainPage.xamlを開き、XAMLに名前空間を追加します。

xmlns:UniversalWrapPanel="using:Gregstoll" 
+0

'Panel'を挿入できません:'パネルは抽象で暗黙の値を含んでいる必要があります ' – Qeeet

+0

@Qetetは更新を試してみます。 –

+0

は機能しません。まず、WPToolKitをインストールした 'WrapPanel'を試しました。第2に 'UniversalWrapPanel'はナゲットからパッケージをインストールできません。パッケージにはv8.1用のアセンブリは含まれていません – Qeeet