WPF组合框之间的额外空间(WPF combobox extra space between entries)

编程入门 行业动态 更新时间:2024-10-27 02:30:40
WPF组合框之间的额外空间(WPF combobox extra space between entries)

我有一个充满少量条目的组合框,但其中一些组合框之间有相当多的空白。

即使在更改字体大小后,此空间仍然可见。 以下是XAML代码:

<ComboBox Grid.Row="1" Grid.Column="3" DisplayMemberPath="[ColumnName]" FontSize="18" HorizontalAlignment="Left" ItemsSource="{Binding Path=[TableName], NotifyOnSourceUpdated=True}" Width="250"/>

ColumnName和TableName来自我的SQL表中。

在视图模型中,我有这样的代码:

PropertyInViewModel = DataModel.TableName.ToList();

我的视图模型中的属性是这样的:

private IEnumerable<TableName> _propertyInViewModel; public IEnumerable<TableName> ProptertyInViewModel { get { return _propertyInViewModel; } set { _propertyInViewModel= value; this.RaisePropertyChanged(); } }

我在这个表中有另一列,它只是上图中条目的主键。 如果我显示主键,我没有额外的空间。 我不确定问题是什么,但改变字体大小和组合框的宽度似乎不能解决问题。 任何帮助将是伟大的!

I have a combobox that is filled with a handful of entries, but some of them have quite a bit of whitespace between them.

This space is still visible even after I change the font size. Below is the XAML code:

<ComboBox Grid.Row="1" Grid.Column="3" DisplayMemberPath="[ColumnName]" FontSize="18" HorizontalAlignment="Left" ItemsSource="{Binding Path=[TableName], NotifyOnSourceUpdated=True}" Width="250"/>

where ColumnName and TableName come from my table in SQL.

In the view model I have this code:

PropertyInViewModel = DataModel.TableName.ToList();

where my property in my view model is this:

private IEnumerable<TableName> _propertyInViewModel; public IEnumerable<TableName> ProptertyInViewModel { get { return _propertyInViewModel; } set { _propertyInViewModel= value; this.RaisePropertyChanged(); } }

I have another column in this table that is simply a primary key for the entries in the picture above. If I display the primary keys, I don't have the extra space. I'm not sure what the issue is, but changing the font size and the combobox's width did not seem to fix the issue. Any help would be great!

最满意答案

你的XAML没有任何问题。

确保源集合不包含ColumnName属性返回空string或null任何记录

还要确保其他记录不包含任何空行。

There is nothing wrong with your XAML.

Make sure that the source collection doesn't include any records where the ColumnName property returns an empty string or null

Also make sure that the other records don't include any empty lines.

更多推荐

本文发布于:2023-07-26 17:44:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1278865.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:组合   空间   WPF   combobox   entries

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!