2016-03-21 10 views
0

以下のコードは、それぞれのアイテムが自然に異なる高さになっていても、アイテムのグリッドを示しています。たぶん私は何かの高さを設定するはずですが、私はそのことが何であるか、または私が必要とする価値をどこで得るのか分かりません。ItemsControlアイテムをずらしたラップで表示するにはどうすればいいですか

I want I get 
a c  a c 
a c  a c 
a d  a . 
b d  b d 
b d  b d 
      . d 

コード:

 <ItemsControl ItemsSource="{Binding XPath=*}" Margin="20,0,0,0"> 
      <ItemsControl.ItemsPanel> 
       <ItemsPanelTemplate> 
        <WrapPanel 
         Orientation="vertical" <!-- edit: adding this line solved it --> 
        /> 
       </ItemsPanelTemplate> 
      </ItemsControl.ItemsPanel> 
      <ItemsControl.ItemTemplate> 
       <DataTemplate> 
       <W3V:ControlChooser Content="{Binding}"/> 
       </DataTemplate> 
      </ItemsControl.ItemTemplate> 
    </ItemsControl> 

答えて

1

項目の順序は左から右にする必要がない場合には、WrapPanel.Orientationを変更することが十分でなければなりません。

編集:はちょうどそれをテストし、それは私が期待どおりに動作:

enter image description here

コード基礎:

<ItemsControl ItemsSource="{Binding Users}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> 
    <ItemsControl.ItemContainerStyle> 
     <Style TargetType="ContentPresenter"> 
      <Setter Property="Height" Value="{Binding Height}"></Setter> 
      <Setter Property="Width" Value="200px"></Setter> 
     </Style> 
    </ItemsControl.ItemContainerStyle> 
    <ItemsControl.ItemsPanel> 
     <ItemsPanelTemplate> 
      <WrapPanel Orientation="Vertical"></WrapPanel> 
     </ItemsPanelTemplate> 
    </ItemsControl.ItemsPanel> 
</ItemsControl> 
+1

を、彼はただではないポジショニング、彼が望んでいるの順序を取得しているように見えます。 –

+0

@BradleyUffner:項目が転置的に対称であるとすれば、意図した注文が何であるかを知ることは困難です。多分注文は問題ではないかもしれません。 –

+0

私はそれらの数値が2 x 5グリッド上に配置されているかのようにアイテムの高さ(それらの下のドットを含む)だと思います。彼は不均一な行を得ようとしているようですが、各行が一番上に並ぶようにきれいに壊しています。 –

関連する問題