Reputation: 2550
I'm creating an app where a user is filling in a form with several text boxes. They can add or remove text boxes based on how many they wish. I'm having trouble with adding and positioning a new control. Here's what I have so far:
TextBox textOne = new TextBox();
textOne.Text = "Lorem ipsum";
textOne.Height = 20;
textOne.Width = 50;
textOne.Margin.Left = 20;
The problem is the final line where I try to set the margin to 20 and it says: "Cannot modify the return value of 'System.Windows.FrameworkElement.Margin' because it is not a variable".
Am I not using the correct method (well clearly I'm not) or am I just going about this the completely wrong way?
Upvotes: 0
Views: 79
Reputation: 12655
try it with Thickness
object:
textOne.Margin = new Thickness(20, 0, 0, 0); // left, top, right, bottom
Upvotes: 1