There was a situation that developers want to add controls to canvas according to some arguments. So some codes as below. Button checkBtn = new Button(); checkBtn.Click += new RoutedEventHandler(checkBtn_Click); Canvas.SetLeft(checkBtn, 405); Canvas.SetTop(checkBtn, interval * (i - 1)); canvasName.Children.