2012-02-14 23 views
1

私のwpfアプリケーションにComboBoxがあり、CheckBoxを含むリストボックスを追加して、カテゴリから複数の項目を選択できるようにしてください。ComboBox内のリストボックスを垂直方向にスクロールする方法

** ListBoxesは、高さをAutoに設定していてもスクロール可能ではないため、CheckBox全体を表示できませんでした。この質問を考える上でお時間を事前に

THANKS

* スタイリングは、以下の以来、雨のステップは残り*

  <ComboBox Height="23" HorizontalAlignment="Left" Margin="20,10,0,0" Name="comboBox1" VerticalAlignment="Top" Width="120" Text="Hamburger & Sandwiches" StaysOpenOnEdit="True"> 

    <ListBox BorderThickness="0,0,2,0" ScrollViewer.VerticalScrollBarVisibility="Visible" 
       SelectionMode="Multiple" Background="#E3418D00" Focusable="False" SnapsToDevicePixels="True"> 
        <ListBox.BorderBrush> 
        <SolidColorBrush /> 
       </ListBox.BorderBrush> 
       <CheckBox Foreground="Cyan" FontFamily="Lucida Sans" Content="Chicken Wrap" ClickMode="Release" BorderBrush="#FFF58B09" Name="chkChickenWrap"> 
        <CheckBox.Background> 
         <SolidColorBrush /> 
        </CheckBox.Background> 
       </CheckBox> 
       <CheckBox Name="chkRibeyeSteakWrap" Content="Ribeye Steak Wrap" FontFamily="Lucida Sans" Foreground="Cyan" BorderBrush="Orange"> 
        <CheckBox.Background> 
         <SolidColorBrush /> 
        </CheckBox.Background> 
       </CheckBox> 
       <CheckBox Name="chkShreddedBeefWrap" Foreground="Cyan" FontFamily="Lucida Sans" Content="Shredded Beef Wrap" BorderBrush="Orange"> 
        <CheckBox.Background> 
         <SolidColorBrush /> 
        </CheckBox.Background> 
       </CheckBox> 
       <CheckBox Name="chkCheeseburgerParadiseWrap" Foreground="Cyan" FontFamily="Lucida Sans" BorderBrush="Orange" Content="Cheeseburger Paradise Wrap"> 
        <CheckBox.Background> 
         <SolidColorBrush /> 
        </CheckBox.Background> 
       </CheckBox> 
       <CheckBox Name="chkVeggieWrap" BorderBrush="Orange" Content="Veggie Wrap" Foreground="Cyan" FontFamily="Lucida Sans"> 
        <CheckBox.Background> 
         <SolidColorBrush /> 
        </CheckBox.Background> 
       </CheckBox> 
       <CheckBox Name="chkChiliBurger" Foreground="Cyan" FontFamily="Lucida Sans" Content="Chili Burger" BorderBrush="Orange"> 
        <CheckBox.Background> 
         <SolidColorBrush /> 
        </CheckBox.Background> 
       </CheckBox> 
       <CheckBox Name="chkTiajuanaTorpedo" BorderBrush="Orange" Content="Tiajuana Torpedo" FontFamily="Lucida Sans" Foreground="Cyan"> 
        <CheckBox.Background> 
         <SolidColorBrush /> 
        </CheckBox.Background> 
       </CheckBox> 
       <CheckBox Foreground="Cyan" FontFamily="Lucida Sans" Content="Stuffed Burger" BorderBrush="Orange" Name="chkStuffedBurger"> 
        <CheckBox.Background> 
         <SolidColorBrush /> 
        </CheckBox.Background> 
       </CheckBox> 
       <CheckBox Name="chkCheeseBurger" BorderBrush="Orange" Content="Cheese Burger" Foreground="Cyan" FontFamily="Lucida Sans"> 
        <CheckBox.Background> 
         <SolidColorBrush /> 
        </CheckBox.Background> 
       </CheckBox> 
       <CheckBox Foreground="Cyan" FontFamily="Lucida Sans" Content="Patty Melt" BorderBrush="Orange" Name="chkPattyMelt"> 
        <CheckBox.Background> 
         <SolidColorBrush /> 
        </CheckBox.Background> 
       </CheckBox> 
       <CheckBox Foreground="Cyan" FontFamily="Lucida Sans" Content="Harry's Big Barn Burger" BorderBrush="Orange" Name="chkHarrysBigBarnBurger"> 
        <CheckBox.Background> 
         <SolidColorBrush /> 
        </CheckBox.Background> 
       </CheckBox> 
       <CheckBox Name="chkTheReuban" BorderBrush="Orange" Content="The Reuban" FontFamily="Lucida Sans" Foreground="Cyan"> 
        <CheckBox.Background> 
         <SolidColorBrush /> 
        </CheckBox.Background> 
       </CheckBox> 
       <CheckBox Name="chkBBQBeefSandwich" Foreground="Cyan" FontFamily="Lucida Sans" Content="BBQ Beef Sandwich" BorderBrush="Orange"> 
        <CheckBox.Background> 
         <SolidColorBrush /> 
        </CheckBox.Background> 
       </CheckBox> 
       <CheckBox Name="chkSteakSandwich" BorderBrush="Orange" Content="Steak Sandwich" FontFamily="Lucida Sans" Foreground="Cyan"> 
        <CheckBox.Background> 
         <SolidColorBrush /> 
        </CheckBox.Background> 
       </CheckBox> 
       <CheckBox Name="chkFrenchDip" BorderBrush="Orange" Content="French Dip" FontFamily="Lucid sans" Foreground="Cyan"> 
        <CheckBox.Background> 
         <SolidColorBrush /> 
        </CheckBox.Background> 
       </CheckBox> 
       <CheckBox Foreground="Cyan" FontFamily="Lucida Sans" Content="Chili Dog" BorderBrush="Orange" Name="chkChiliDog"> 
        <CheckBox.Background> 
         <SolidColorBrush /> 
        </CheckBox.Background> 
       </CheckBox> 
       <CheckBox Name="chkChickenFriedSteakSandwich" BorderBrush="Orange" Content="Chicken Fried Steak Sandwich" FontFamily="Lucida Sans" Foreground="Cyan"> 
        <CheckBox.Background> 
         <SolidColorBrush /> 
        </CheckBox.Background> 
       </CheckBox> 
       <CheckBox Name="chkClubSandwich" BorderBrush="Orange" Content="Club Sandwich" Foreground="Cyan" FontFamily="Lucida Sans"> 
        <CheckBox.Background> 
         <SolidColorBrush /> 
        </CheckBox.Background> 
       </CheckBox> 
       <CheckBox Name="chkCajunCatfishSandwich" Foreground="Cyan" FontFamily="Lucida Sans" Content="Cajun Catfish Sandwich" BorderBrush="Orange"> 
        <CheckBox.Background> 
         <SolidColorBrush /> 
        </CheckBox.Background> 
       </CheckBox> 
       <CheckBox Name="chkEggAndCucumberTeaSandwich" BorderBrush="Orange" Content="Egg &amp; Cucumber Tea Sandwiches" FontFamily="Lucid sans" Foreground="Cyan"> 
        <CheckBox.Background> 
         <SolidColorBrush /> 
        </CheckBox.Background> 
       </CheckBox> 
       <CheckBox Name="chkSmokedSalmonCrosini" BorderBrush="Orange" Content="Smoked Salmon Crosini Recipe" FontFamily="Lucida Sans" Foreground="Cyan"> 
        <CheckBox.Background> 
         <SolidColorBrush /> 
        </CheckBox.Background> 
       </CheckBox> 
      </ListBox> 
     </ComboBox> 

答えて

1

使用ScrollViewerのに適用されるCombBoxesの一つです。

すべてのスクロール可能なコントロールをスクロールビューアーに入れます。

1

ListBoxアイテムを縦方向にスクロールするには、アイテムのパネルの最大高さを指定します。

コードのこの作品は、あなたが望むものを正確に行います。

<ComboBox Height="23" HorizontalAlignment="Left" Margin="20,10,0,0" Name="comboBox1" VerticalAlignment="Top" Width="120" Text="Hamburger and Sandwiches"> 
    <ListBox BorderThickness="0,0,2,0" ScrollViewer.VerticalScrollBarVisibility="Visible" 
     SelectionMode="Multiple" Background="#E3418D00" Focusable="False" SnapsToDevicePixels="True"> 

     <ListBox.ItemsPanel> 
      <ItemsPanelTemplate> 
       <StackPanel Orientation="Vertical" MaxHeight="200"/> 
      </ItemsPanelTemplate> 
     </ListBox.ItemsPanel> 

     <ListBox.BorderBrush> 
      <SolidColorBrush /> 
     </ListBox.BorderBrush> 
     <CheckBox Foreground="Cyan" FontFamily="Lucida Sans" Content="Chicken Wrap" ClickMode="Release" BorderBrush="#FFF58B09" Name="chkChickenWrap"> 
      <CheckBox.Background> 
       <SolidColorBrush /> 
      </CheckBox.Background> 
     </CheckBox> 
     <CheckBox Name="chkRibeyeSteakWrap" Content="Ribeye Steak Wrap" FontFamily="Lucida Sans" Foreground="Cyan" BorderBrush="Orange"> 
      <CheckBox.Background> 
       <SolidColorBrush /> 
      </CheckBox.Background> 
     </CheckBox> 
     <CheckBox Name="chkShreddedBeefWrap" Foreground="Cyan" FontFamily="Lucida Sans" Content="Shredded Beef Wrap" BorderBrush="Orange"> 
      <CheckBox.Background> 
       <SolidColorBrush /> 
      </CheckBox.Background> 
     </CheckBox> 
     <CheckBox Name="chkCheeseburgerParadiseWrap" Foreground="Cyan" FontFamily="Lucida Sans" BorderBrush="Orange" Content="Cheeseburger Paradise Wrap"> 
      <CheckBox.Background> 
       <SolidColorBrush /> 
      </CheckBox.Background> 
     </CheckBox> 
     <CheckBox Name="chkVeggieWrap" BorderBrush="Orange" Content="Veggie Wrap" Foreground="Cyan" FontFamily="Lucida Sans"> 
      <CheckBox.Background> 
       <SolidColorBrush /> 
      </CheckBox.Background> 
     </CheckBox> 
     <CheckBox Name="chkChiliBurger" Foreground="Cyan" FontFamily="Lucida Sans" Content="Chili Burger" BorderBrush="Orange"> 
      <CheckBox.Background> 
       <SolidColorBrush /> 
      </CheckBox.Background> 
     </CheckBox> 
     <CheckBox Name="chkTiajuanaTorpedo" BorderBrush="Orange" Content="Tiajuana Torpedo" FontFamily="Lucida Sans" Foreground="Cyan"> 
      <CheckBox.Background> 
       <SolidColorBrush /> 
      </CheckBox.Background> 
     </CheckBox> 
     <CheckBox Foreground="Cyan" FontFamily="Lucida Sans" Content="Stuffed Burger" BorderBrush="Orange" Name="chkStuffedBurger"> 
      <CheckBox.Background> 
       <SolidColorBrush /> 
      </CheckBox.Background> 
     </CheckBox> 
     <CheckBox Name="chkCheeseBurger" BorderBrush="Orange" Content="Cheese Burger" Foreground="Cyan" FontFamily="Lucida Sans"> 
      <CheckBox.Background> 
       <SolidColorBrush /> 
      </CheckBox.Background> 
     </CheckBox> 
     <CheckBox Foreground="Cyan" FontFamily="Lucida Sans" Content="Patty Melt" BorderBrush="Orange" Name="chkPattyMelt"> 
      <CheckBox.Background> 
       <SolidColorBrush /> 
      </CheckBox.Background> 
     </CheckBox> 
     <CheckBox Foreground="Cyan" FontFamily="Lucida Sans" Content="Harry's Big Barn Burger" BorderBrush="Orange" Name="chkHarrysBigBarnBurger"> 
      <CheckBox.Background> 
       <SolidColorBrush /> 
      </CheckBox.Background> 
     </CheckBox> 
     <CheckBox Name="chkTheReuban" BorderBrush="Orange" Content="The Reuban" FontFamily="Lucida Sans" Foreground="Cyan"> 
      <CheckBox.Background> 
       <SolidColorBrush /> 
      </CheckBox.Background> 
     </CheckBox> 
     <CheckBox Name="chkBBQBeefSandwich" Foreground="Cyan" FontFamily="Lucida Sans" Content="BBQ Beef Sandwich" BorderBrush="Orange"> 
      <CheckBox.Background> 
       <SolidColorBrush /> 
      </CheckBox.Background> 
     </CheckBox> 
     <CheckBox Name="chkSteakSandwich" BorderBrush="Orange" Content="Steak Sandwich" FontFamily="Lucida Sans" Foreground="Cyan"> 
      <CheckBox.Background> 
       <SolidColorBrush /> 
      </CheckBox.Background> 
     </CheckBox> 
     <CheckBox Name="chkFrenchDip" BorderBrush="Orange" Content="French Dip" FontFamily="Lucid sans" Foreground="Cyan"> 
      <CheckBox.Background> 
       <SolidColorBrush /> 
      </CheckBox.Background> 
     </CheckBox> 
     <CheckBox Foreground="Cyan" FontFamily="Lucida Sans" Content="Chili Dog" BorderBrush="Orange" Name="chkChiliDog"> 
      <CheckBox.Background> 
       <SolidColorBrush /> 
      </CheckBox.Background> 
     </CheckBox> 
     <CheckBox Name="chkChickenFriedSteakSandwich" BorderBrush="Orange" Content="Chicken Fried Steak Sandwich" FontFamily="Lucida Sans" Foreground="Cyan"> 
      <CheckBox.Background> 
       <SolidColorBrush /> 
      </CheckBox.Background> 
     </CheckBox> 
     <CheckBox Name="chkClubSandwich" BorderBrush="Orange" Content="Club Sandwich" Foreground="Cyan" FontFamily="Lucida Sans"> 
      <CheckBox.Background> 
       <SolidColorBrush /> 
      </CheckBox.Background> 
     </CheckBox> 
     <CheckBox Name="chkCajunCatfishSandwich" Foreground="Cyan" FontFamily="Lucida Sans" Content="Cajun Catfish Sandwich" BorderBrush="Orange"> 
      <CheckBox.Background> 
       <SolidColorBrush /> 
      </CheckBox.Background> 
     </CheckBox> 
     <CheckBox Name="chkEggAndCucumberTeaSandwich" BorderBrush="Orange" Content="Egg &amp; Cucumber Tea Sandwiches" FontFamily="Lucid sans" Foreground="Cyan"> 
      <CheckBox.Background> 
       <SolidColorBrush /> 
      </CheckBox.Background> 
     </CheckBox> 
     <CheckBox Name="chkSmokedSalmonCrosini" BorderBrush="Orange" Content="Smoked Salmon Crosini Recipe" FontFamily="Lucida Sans" Foreground="Cyan"> 
      <CheckBox.Background> 
       <SolidColorBrush /> 
      </CheckBox.Background> 
     </CheckBox> 
    </ListBox> 
</ComboBox> 
関連する問題