我有listBox(在代碼後面添加),並且當Items.Count> 4時我想設置最後一個項目的可見性。我有充滿按鈕的列表框。WPF在列表框中設置項目的可見性 - 後面的代碼
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);
}
This previousButton.Visibility
does not work。
錯誤在哪裏?
嘗試Visibility.Hidden – Tico
你必須點擊OK,以進行下一步一旦你調用MessageBox.Show其他UI線程將等待,你將永遠不會設置可見性:) :) –
不工作.. –