【发布时间】:2014-11-02 11:58:21
【问题描述】:
我正在尝试使用数组中的值设置椭圆的边距。我到目前为止的代码是这样的:
private void Dots()
{
string[] strArray = new string[] { "387,10,396,432"}; // this is the margin
foreach (string str in strArray)
{
Ellipse a = new Ellipse();
a.Fill = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
a.Margin = new Thickness(Convert.ToInt32(str)); // the margin goes here
a.Width = 25;
a.Height = 25;
a.Tap += DotTap;
LevelPanel1.Children.Add(a);
}
}
现在的问题是我收到错误“输入字符串的格式不正确”。 边距最终应如下所示:
a.Margin = new Thickness(387,10,396,432);
现在有人可以解决这个问题吗? (ps 我是 C# 编码的新手,所以如果这是一个非常愚蠢的问题,我很抱歉。)
提前致谢。
【问题讨论】:
标签: c# xaml windows-phone-8 windows-phone windows-phone-8.1