【发布时间】:2023-03-04 02:15:01
【问题描述】:
我在WrapPanel 中有Buttons,它们是动态创建的。我想在Click_event 上更改特定Button 的高度/宽度。
这是我正在做的事情:
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;
}
}
}
我在上面尝试过,但它变得空了,不知道为什么。 请帮忙 谢谢
【问题讨论】:
标签: c# wpf button mouseevent wrappanel