Hey guys, I'm trying to add some controls via code, but I have one little problem. I have checkboxes inside WrapPanel. Checkboxes are transformed to be 1.5x bigger. When I changing size of window, they're colliding with each other. Without transforming everything is normal. How to fix it?
List<System.Windows.Controls.CheckBox> CheckboxList = new List<CheckBox>();
public List<string> Users = new List<string> { "First Student", "Very First Student", "Second Student", "Student Student" };
for (int i = 0; i < Users.Count; i++)
{
CheckboxList.Add(new System.Windows.Controls.CheckBox());
heckboxList[i].RenderTransform = new ScaleTransform(1.5,1.5);
CheckboxList[i].Content = Users[i];
CheckboxList[i].Margin = new Thickness(5, 5, 5, 0);
Panel.Children.Add(CheckboxList[i]);
}
}
The RenderTransform
property is used to get/set transform that affects only the control's appearance and does not affect its layout logic. What you want though is to transform your controls both logically and visually, and to achieve that you should use LayoutTransform
property instead.