我想在函数中初始化并显示一个椭圆(WPF 形状)。椭圆的名称应该作为参数提供给函数。
有没有可能做这样的事情?
编辑:
给出以下内容:
private void A1_Click(object sender, RoutedEventArgs e)
{
textBox1.Text = "Feld A1 gedrückt";
//Spielstein setzen
//Rêgeln überprüfen
myEllipse = new Ellipse();
myEllipse.Fill = System.Windows.Media.Brushes.Black;
myEllipse.HorizontalAlignment = HorizontalAlignment.Left;
myEllipse.VerticalAlignment = VerticalAlignment.Top;
myEllipse.Margin = new Thickness(2, 2, 0, 0);
myEllipse.Width = 45;
myEllipse.Height = 45;
grid3.Children.Add(myEllipse);
A1.IsHitTestVisible = false;
}
我想要做的是从字符串变量中获取名称(“myEllipse”)。例如:
string name = 'myEllipse';
name = newEllipse();
myEllipse.Fill = System.Windows.Media.Brushes.Black;