相关疑难解决方法(0)

ItemContainerGenerator.ContainerFromItem()返回null?

我有一些奇怪的行为,我似乎无法解决.当我遍历ListBox.ItemsSource属性中的项目时,我似乎无法获取容器?我期待看到一个ListBoxItem返回,但我只得到null.

有任何想法吗?

这是我正在使用的一些代码:

this.lstResults.ItemsSource.ForEach(t =>
    {
        ListBoxItem lbi = this.lstResults.ItemContainerGenerator.ContainerFromItem(t) as ListBoxItem;

        if (lbi != null)
        {
            this.AddToolTip(lbi);
        }
    });
Run Code Online (Sandbox Code Playgroud)

ItemsSource当前设置为Dictionary并且包含许多KVP.

wpf containers listbox itemssource

33
推荐指数
5
解决办法
4万
查看次数

标签 统计

containers ×1

itemssource ×1

listbox ×1

wpf ×1