0
嗨我需要能夠生成帶有文本的動態矩形。我現在有這個問題,那我不是能夠在矩形中添加文本我如何添加文本到c中的矩形#
我產生這裏的矩形:
public void ShowAppointements()
{
foreach (Termin termin in MainWindow.termine)
{
if (termin.week == Int32.Parse(txtWeek.Content.ToString()))
{
Rectangle rectangle = new Rectangle();
Kalender.Children.Add(rectangle);
Grid.SetRow(rectangle, termin.start + 2);
Grid.SetColumn(rectangle, termin.day * 2 - 1);
Grid.SetColumnSpan(rectangle, 2);
Grid.SetRowSpan(rectangle, termin.end - termin.start);
rectangle.Fill = termin.color;
}
}
}
尋找其他類似的問題的回答總是,只是避免使用矩形但idealy我想繼續使用它們。
把TextBlock放到同一個Grid單元格中。 – Clemens