我有Buttons
,WrapPanel
那些是动态创建的。我想更改特定Button
on的高度/宽度Click_event
。
这是我在做什么:
for (int i = 1; i <= count; i++)
{
btn = new Button();
btn.MinHeight = 22;
btn.MinWidth = 22;
btn.Content = i.ToString();
int _id = id++;
btn.Name = "btn"+_id.ToString();
wrpQuestionsMap.Children.Add(btn);
btn.Click += new RoutedEventHandler(btn_Click);
}
private void btnNext_Click_1(object sender, RoutedEventArgs e)
{
if (this.view.CurrentPosition < this.view.Count - 1)
{
this.view.MoveCurrentToNext();
Button b = (Button)this.wrpQuestionsMap.FindName("btn"+view.CurrentPosition.ToString());
if (b != null)
{
b.Width = 30;
}
}
}
我在上面尝试过,但它变得空了,不知道为什么。请帮忙谢谢