我有列表框(在后面的代码中添加),我想在 Items.Count > 4 时设置最后一项的可见性。我有一个充满按钮的列表框。
private void movingOfButtons(ListBox list, int index)
{
Control previousButton = (Control)list.Items.GetItemAt(list.Items.Count - 1);
int itemCounts = ktery.Items.Count;
indexButton = index;
// create new buttons
addNewButton("Sound");
addNewButton("addSound");
mainCycle(list);
// this does not work - it show only messageBox
if (itemCounts >= 4)
{
MessageBox.Show("" + previousButton.Name);
previousButton.Visibility = Visibility.Collapsed;
}
(list).Items.RemoveAt(index);
}
这previousButton.Visibility
不起作用。
错误在哪里?