2013-02-27 70 views
1

如果我將高度設置得大一些,它會超出專用空間。我該如何解決這個問題?我能以某種方式拿走組合框中的所有空白空間嗎?組合框太高

請參見下圖。由於此問題,您無法閱讀文本「-Vessel Type-」。

enter image description here

代碼:

<ComboBox Name="comboBoxVesselType" Width="152" Margin="8,2,0,0" Height="15" Padding="0,0,0,0" BorderThickness="0" FontSize="10" MouseEnter="canvasSelection_MouseEnter" MouseLeave="canvasSelection_MouseLeave"> 
     <ListBoxItem Content="- Vessel Type- " IsSelected="True" /> 
    </ComboBox> 
+3

爲什麼要在一個ComboBox中放置一個ListBoxItem? – 2013-02-27 22:21:03

+1

你有沒有嘗試刪除邊距? – 2013-02-27 22:21:32

回答

0

嘗試將ComboBoxVerticalContentAlignmentTop

例子:

<ComboBox VerticalContentAlignment="Top" .................... 

結果:

enter image description here

1

你爲什麼把一個ListBoxItem的組合框裏面?

反正嘗試負值用於填充像

Paddin="0,-5, 0, 0" 
0

因此,組合框的項目是不是一個ListBoxItem但ComboBoxItem。這解決了它。

 <ComboBox Name="comboBoxVesselType" Width="152" Margin="8,2,0,0" Height="15" Padding="0,0,0,0" Background="{x:Null}" BorderThickness="0" FontSize="10" MouseEnter="canvasSelection_MouseEnter" MouseLeave="canvasSelection_MouseLeave"> 
      <ComboBoxItem Content="- Vessel Type- " IsSelected="True" /> 
     </ComboBox> 
0

您可以使用ComboBoxItem代替ListBoxItem。您也可以將對齊設置爲「居中」並避免使用固定寬度。這解決了它。

<ComboBox Name="comboBoxVesselType" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="8,2,0,0" Height="15" 
Padding="0,0,0,0" Background="{x:Null}" BorderThickness="0" FontSize="10" 
MouseEnter="canvasSelection_MouseEnter" MouseLeave="canvasSelection_MouseLeave"> 
<ComboBoxItem Content="- Vessel Type- " IsSelected="True" /> 
</ComboBox>