1

嗨,我需要在矩形内绘制一个复选框。c# WPF 中是否有任何预定义的方法。或者我如何在 WPF 中实现这个场景。

4

2 回答 2

4

你可以试试这个:

 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));
于 2015-06-17T11:14:02.250 回答
-1

1.) 创建矩形

2.) 创建复选框

3.) 使用 rectangle.Controls.Add(checkbox)

希望这可以帮助 :)

于 2015-02-26T12:55:52.267 回答