2013-02-01 2 views
0

드롭 다운이 열리는 동안 콤보 상자의 크기를 변경하는 방법이 있으면 궁금합니다.드롭 다운의 WPF ComboBox 변경 크기

Grid에 래핑 된 Label 및 ComboBoxes가있는 StackPanel이 있습니다.

<StackPanel x:Name="stackPanel"> 
    <Grid> 
     <Label Content="A:"/> 
     <ComboBox x:Name="cbA"/> 
    </Grid> 
    <Grid> 
     <Label Content="B:"/> 
     <ComboBox x:Name="cbB"/> 
    </Grid> 
</StackPanel> 

Looks like: 
Label ComboBox 
Label ComboBox 

내가 콤보 상자를 열면, 그것은 중복과 같이 NOT한다 : 나는 희망

Label ComboBox 
     DropDown 
     DropDown 
     DropDown 
Label ComboBox 

당신은 당신이 enter image description here

이처럼 원하는 나 :

+0

IMO는 사용자가 콤보 상자를 클릭하여 열 때마다 콤보 상자 아래의 모든 시각적 요소가 아래로 이동하기 때문에 UX 관점에서 볼 때 편안하지 않을 것입니다. –

답변

1

스페이서 그리드 또는 다른 요소를 두 Comboboxes 사이에 넣으시겠습니까? cbAMaxDropDownHeight을 설정해야합니다. 기본 높이가 허용하는 것보다 적은 수의 요소가 있으면 공간이 너무 커집니다.

 <StackPanel x:Name="stackPanel"> 
      <StackPanel.Resources> 
       <BooleanToVisibilityConverter x:Key="VisibilityConverter"/> 
      </StackPanel.Resources> 
      <Grid> 
       <Label Content="A:"/> 
       <ComboBox x:Name="cbA" MaxDropDownHeight="100" ItemsSource="{Binding Path=ComboTest}"/> 
      </Grid> 
      <Grid x:Name="Spacer" Height="{Binding ElementName=cbA, Path=MaxDropDownHeight}" 
        Visibility="{Binding ElementName=cbA, Path=IsDropDownOpen, Converter={StaticResource VisibilityConverter}}"/> 
      <Grid> 
       <Label Content="B:"/> 
       <ComboBox x:Name="cbB"/> 
      </Grid> 
     </StackPanel> 
+0

깔끔하게 설명 된 대답 .. 좋은 – Smaug

+0

@ RameshMuthiah - 당신은 아마도 젤리의 대답을 upvote해야합니다;) –

0

을 이해 ListPicker 컨트롤입니다. 콤보 박스는 이런 식으로 작동하지 않습니다.

+0

그게 전부 내가 상상 한 것 – user1796724

관련 문제