2012-02-29 54 views
2

我有以下組合框:Silverlight的組合框空項目高度

<ComboBox x:Name="cmb2" ItemsSource="{Binding SignCollection, Mode=OneWay}"/> 

註冊收藏是列表和它的第一個元素爲空。我的問題是,當我運行我的應用程序時,通常顯示的所有項目,但第一個(這是空)具有非常小的高度(它仍然存在並可選擇)。所以,我的問題是我如何強制它具有與其他一切相同的高度。

+0

你真的不應該在你的集合中包含一個空值...一個更好的方法來處理事情是有一個公共布爾IsNull {獲取;私人設置; }' - 這是表示空值的虛假方式。 – 2012-02-29 12:56:00

+0

我實際上也有雙向綁定selecteditem可空的屬性。我可以寫轉換器,但我很懶。 Zortkun對我提供的解決方案表示感謝。 – noaRAVE 2012-02-29 13:15:18

回答

4

你可以試試嗎?

<ComboBox x:Name="cmb2" ItemsSource="{Binding SignCollection, Mode=OneWay}"> 
    <ComboBox.ItemContainerStyle> 
     <Style TargetType="ComboBoxItem"> 
       <Setter Property="Height" Value="50"/> 
     </Style> 
    </ComboBox.ItemContainerStyle> 
</ComboBox> 
  • 50:例如固定高度

希望它能幫助。

0

你可以試試這個..hope這會幫助你。

<ComboBox x:Name="cmbType" SelectedIndex="0" Grid.Row="0" Grid.Column="2" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,5,0,0" Width="250" Height="23" > 
        <ComboBoxItem>--Select Type--</ComboBoxItem> 
        <ComboBoxItem>Errors</ComboBoxItem> 
        <ComboBoxItem>Logs</ComboBoxItem> 
</ComboBox> 

謝謝。 enter image description here