【问题标题】:Silverlight combobox null item heightSilverlight 组合框空项高度
【发布时间】:2012-02-29 12:30:24
【问题描述】:

我有以下组合框:

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

Sign Collection 是 List 并且它的第一个元素是 null。我的问题是,当我运行我的应用程序时,所有项目都正常显示,但第一个项目(为空)的高度非常小(它仍然存在并且可以选择)。所以,我的问题是如何强制它与其他所有东西具有相同的高度。

【问题讨论】:

  • 你真的不应该在你的集合中包含一个空值......处理事情的更好方法是有一个public bool IsNull { get; private set; }——这是一种表示空值的虚假方式。跨度>
  • 我实际上也有将 selecteditem 双向绑定到可为空的属性。我可以写转换器,但我很懒。 Zortkun 感谢您提供解决方案。

标签: c# .net silverlight xaml combobox


【解决方案1】:

你可以试试这个吗?

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

希望对你有帮助。

【讨论】:

    【解决方案2】:

    你可以试试这个。希望对你有帮助。

    <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>   
    

    谢谢。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-02
      • 1970-01-01
      • 1970-01-01
      • 2011-03-30
      相关资源
      最近更新 更多