2016-12-13 3 views
0

リストボックス内に表示される製品のリストを作成しています。私は水平にスクロールリストを持っていますが、リストボックスが水平にスクロールを開始する前に2行を移入するのに十分な高さであっても、アイテムの1行しか取得しません。WPF水平リストボックスの縦方向の塗りつぶし

私のWPFコードの一部です。私が探している

<DataTemplate x:Key="productTemplate"> 
    <WrapPanel Orientation="Horizontal" Width="10" Height="10"> 
      <Image Source="{Binding Photo}" Stretch="Fill" HorizontalAlignment="Center" VerticalAlignment="Center" Width="288" Height="320"/> 
      <Label Content="{Binding Name}" /> 
      <Label Content="{Binding Cost}" /> 
    </WrapPanel> 
</DataTemplate> 

<ListBox Width="1334" ItemsSource="{Binding Products}" SelectedItem="{Binding SelectedProduct}" ItemTemplate="{DynamicResource productTemplate}" Height="865" ScrollViewer.HorizontalScrollBarVisibility="Hidden" ScrollViewer.VerticalScrollBarVisibility="Disabled" BorderThickness="0"> 
    <ListBox.Background> 
     <SolidColorBrush Color="White" Opacity="0.85"/> 
    </ListBox.Background> 
    <ListBox.ItemsPanel> 
     <ItemsPanelTemplate> 
      <WrapPanel IsItemsHost="True" /> 
     </ItemsPanelTemplate> 
    </ListBox.ItemsPanel> 
</ListBox> 

enter image description here

すべてのヘルプは素晴らしいことです。

答えて

1

ItemsPanelが垂直方向性を持っている必要がありますし、リストボックスが垂直方向にスクロールしてはならないとして、使用されているWrapPanel:

<ListBox ScrollViewer.VerticalScrollBarVisibility="Disabled" ...> 
    <ListBox.ItemsPanel> 
     <ItemsPanelTemplate> 
      <WrapPanel Orientation="Vertical" /> 
     </ItemsPanelTemplate> 
    </ListBox.ItemsPanel> 
    ... 
</ListBox> 
+0

くそー、この¬¬乾杯(y)をしようとするので、近くにあった、それを引き抜きに – Sjc311

0

たぶん、次のコードがお手伝いします。次のコードは、次のようにイメージをバインドするのに役立ちます。

enter image description here

<ListBox Grid.Column="1" ItemsSource="{Binding Items}" Name="detailList" ScrollViewer.HorizontalScrollBarVisibility="Disabled"> 
    <ListBox.ItemsPanel> 
     <ItemsPanelTemplate> 
      <WrapPanel Orientation="Horizontal"></WrapPanel> 
     </ItemsPanelTemplate> 
    </ListBox.ItemsPanel> 

    <ListBox.ItemTemplate> 
     <DataTemplate> 
      <StackPanel Orientation="Vertical" Width="90"> 
       <Image Width="80" Source="{Binding Type, 
        Converter={x:Static local:HeaderToImageConverter.Instance}}"/> 
       <TextBlock FontSize="11" Text="{Binding Name}" VerticalAlignment="Center"/> 
      </StackPanel> 
     </DataTemplate> 
    </ListBox.ItemTemplate> 
</ListBox> 
関連する問題