私は持っています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;
}
}
}
上記を試しましたが、null になっています。理由がわかりません。助けてください ありがとう