列表框不显示项目 [英] Listbox does not display items

查看:70
本文介绍了列表框不显示项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

很抱歉遇到一个可能是简单问题的错误,但是我在XAML文件中定义了一个列表框,并将其绑定到ObservableObjects列表,它实际上只是一个字符串列表.麻烦的是,当对话框出现时,列表框存在并且为空.

Sorry to bug with what is likely a simple issue, but I've defined a Listbox in my XAML file and I've bound it to a List of ObservableObjects which is really just a list of strings. Trouble is, when the dialog appears, the Listbox is present and is blank.

从XAML:

           < ListBox Name =" NameList" Grid.Column ="1". Grid.Row ="10". Grid.RowSpan ="10".宽度="220". Horizo​​ntalAlignment =左" ItemsSource =""{绑定 名称}"/">

            <ListBox Name="NameList" Grid.Column="1" Grid.Row="10" Grid.RowSpan="10" Width="220" HorizontalAlignment="Left" ItemsSource="{Binding Names}"/>

从我的ViewModel:

From my ViewModel:

      私有ObservableCollection< string> _Names = new ObservableCollection< string>(new [] {"Test1","Test2",,",,",,",,",";, ",",","","TestLast"和"});
        private ObservableCollection<string> _Names = new ObservableCollection<string>(new[] { "Test1", "Test2", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "TestLast" });

推荐答案

其他信息(以防万一).该列表在ComboBox和TreeView中都显示良好.
Additional info in case it helps. The list shows up fine in both a ComboBox and a TreeView. 


这篇关于列表框不显示项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆