WPF 如何获取ListBoxItem 的获得ListBox对象呢?

用listBoxItem.Parent方法不行

测试了Parent可行,如下:

            //取ListBoxItem
            ListBoxItem item = this.listBox1.Items[0] as ListBoxItem;
            MessageBox.Show(item.Content.ToString());

            //反过来取ListBox
            ListBox parent = item.Parent as ListBox;
            MessageBox.Show(parent.Name);

温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答