Hi i need to draw an checkbox within the rectangle.is there any predefined method in c# WPF .or how to i acheive this senario in WPF.
Asked
Active
Viewed 695 times
2 Answers
4
You may try this:
CheckBox checkbox = new CheckBox();
checkbox.Content = "Content";
checkbox.Height = 50;
checkbox.Width = 100;
checkbox.IsChecked = true;
checkbox.HorizontalAlignment = HorizontalAlignment.Left;
VisualBrush vb = new VisualBrush(checkbox);
drawingContext.DrawRectangle(vb, null, new Rect(50, 50, 100, 50));

codertuhin
- 61
- 5
-1
1.) Create the Rectanle
2.) Create the checkbox
3.) use rectangle.Controls.Add(checkbox)
Hope this helps :)

Johan
- 262
- 1
- 15
-
thanks for your reply. but rectangle means in this case i have a rectangle area. not the real rectangle element. – SharpGobi Feb 26 '15 at 12:57
-
should still work all the same, check if there is a .Control on your rectangle area. – Johan Feb 26 '15 at 12:59
-
This is a low-effort answer IMO. Step 2 is basically stating the question. – Josh Noe Mar 14 '19 at 18:26