我有一个填色的矩形,想在中间位置添加一些文字,请给出一些建议。
我有以下矩形,它被涂上了颜色。我想在中间位置添加一些文字,请提供一些解决方案。
我有以下矩形,它被涂上了颜色。我想在中间位置添加一些文字,请提供一些解决方案。
var rect1 = new Rectangle
{
Stroke = new SolidColorBrush(Colors.Red),
Fill = new SolidColorBrush(Colors.Black),
Width = 150,
Height = 100,
VerticalAlignment = System.Windows.VerticalAlignment.Top,
HorizontalAlignment = System.Windows.HorizontalAlignment.Left
};
Grid.SetRow(rect, 0);
TGrid2.Children.Add(rect1);
基本上,我想制作一个拖放功能。矩形1可以被拖动到矩形2上;矩形2只有边框颜色和透明填充体,并在拖放时用拖放的矩形1替换矩形2。
这就是为什么我制作了一个矩形,并尝试找出如何将文本添加到矩形中心作为内容,类似于按钮。
TextBlock
上使用TextWrapping
属性。 - Gusdor