2013-10-20 11 views
6

विंडोज स्टोर ऐप xaml में GRIDVIEW को संपादित करने के लिए कैसे करें ताकि हम क्षैतिज की बजाय लंबवत स्क्रॉल कर सकें। X12ML का उपयोग कर मैं स्क्रॉल-व्यू का उपयोग करके मैन्युअल रूप से एक नया उपयोगकर्ता तत्व बनाना चाहिए या विंडोज स्टोर ऐप के साथ इसे प्राप्त करने का कोई आसान तरीका है।लंबवत स्क्रॉलिंग ग्रिडव्यू एक्सएएमएल विंडोज स्टोर ऐप

<GridView HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ItemsSource="{Binding imagelist}"> 

     <GridView.Resources> 
      <DataTemplate x:Key="DataTemplate1"> 
      <Grid Width="250" Height="250" Tapped="Grid_Tapped"> 
        <Image Source="{Binding imsourceurl}"/> 
       </Grid> 
       </DataTemplate> 

     </GridView.Resources> 

     <GridView.ItemTemplate> 

      <StaticResource ResourceKey="DataTemplate1"/> 
     </GridView.ItemTemplate> 

    </GridView> 
+0

क्या आप इस समय मिल गया है? यदि आपका ग्रिडव्यू क्षैतिज स्क्रॉल कर रहा है तो इसका मतलब है कि सामग्री स्क्रीन से व्यापक है। इसे लंबवत स्क्रॉल करने के लिए आपको अपनी सामग्री को पुनर्व्यवस्थित करना होगा ताकि यह संकुचित हो। अपने वर्तमान एक्सएएमएल को देखे बिना कुछ भी सुझाव देना कठिन होगा। – ChrisF

+0

मैंने xaml पोस्ट किया है –

उत्तर

3

हल बनाए गए कस्टम ग्रिड दृश्य टेम्पलेट

public class AdaptableGridView : GridView 
    { 
     // default itemWidth 
     private const double itemWidth = 100.00; 
     public double ItemWidth 
     { 
      get { return (double)GetValue(ItemWidthProperty); } 
      set { SetValue(ItemWidthProperty, value); } 
     } 
     public static readonly DependencyProperty ItemWidthProperty = 
      DependencyProperty.Register("ItemWidth", typeof(double), typeof(AdaptableGridView), new PropertyMetadata(itemWidth)); 
    // default max number of rows or columns 
    private const int maxRowsOrColumns = 3; 
    public int MaxRowsOrColumns 
    { 
     get { return (int)GetValue(MaxRowColProperty); } 
     set { SetValue(MaxRowColProperty, value); } 
    } 
    public static readonly DependencyProperty MaxRowColProperty = 
     DependencyProperty.Register("MaxRowsOrColumns", typeof(int), typeof(AdaptableGridView), new PropertyMetadata(maxRowsOrColumns)); 


    public AdaptableGridView() 
    { 
     this.SizeChanged += MyGridViewSizeChanged; 
    } 

    private void MyGridViewSizeChanged(object sender, SizeChangedEventArgs e) 
    { 
     // Calculate the proper max rows or columns based on new size 
     this.MaxRowsOrColumns = this.ItemWidth > 0 ? Convert.ToInt32(Math.Floor(e.NewSize.Width/this.ItemWidth)) : maxRowsOrColumns; 
    } 
} 

XAML:

<local:AdaptableGridView ItemWidth="250" x:Name="tumbview" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" ItemsSource="{Binding imagelist}" SelectionChanged="GridView_SelectionChanged" Margin="50,0,0,0" > 
     <GridView.ItemsPanel> 
      <ItemsPanelTemplate> 
       <VariableSizedWrapGrid Orientation="Horizontal" 
             ItemWidth="{Binding ElementName=tumbview, Path=ItemWidth}" 
             MaximumRowsOrColumns="{Binding ElementName=tumbview, Path=MaxRowsOrColumns}"/> 
      </ItemsPanelTemplate> 
     </GridView.ItemsPanel> 

अच्छा ट्यूटोरियल पर: custom grid view tutorial

2

मैंने पाया सबसे आसान तरीका सिर्फ एक ListView का उपयोग किया गया और वस्तुओं को एक लपेटा हुआ ग्रिड बनने के लिए सेट करें।

यह मेरे लिए काम करता

 <ListView 
        Width="1300" 
        Height="1000" 
        Margin="20,0,20,0"> 

      <ListView.ItemsPanel> 
       <ItemsPanelTemplate> 
        <WrapGrid MaximumRowsOrColumns="3" Orientation="Horizontal" /> 
       </ItemsPanelTemplate> 
      </ListView.ItemsPanel> 
     </ListView> 

चेक बाहर http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.wrapgrid.aspx

संबंधित मुद्दे