我想我让它工作了,但现在我面临另一个问题:
首先我创建一个画布:
private void AddItem()
{
Canvas myCanvas = new Canvas();
Canvas myCanvas2 = new Canvas();
myCanvas2.Height = 128;
myCanvas2.Width = 104;
myCanvas.Background = new SolidColorBrush(Colors.Blue);
myCanvas.Height = 200;
myCanvas.Width = 350;
myCanvas2.Margin = new System.Windows.Thickness(5,10,0,0);
myCanvas.Margin = new System.Windows.Thickness(66, 10, 0, 0);
然后我创建三个文本块:
首先:将 TextBlock 添加到第一个 Canvas:
TextBlock TextBlock1= new TextBlock();
TextBlock1.FontSize = 48;
TextBlock1.Text = Fach.Text;
Canvas.SetTop(TextBlock1, 10);
Canvas.SetLeft(TextBlock1, 29);
myCanvas.Children.Add(TextBlock1);
第二:将第二个 TextBlock 添加到第一个 Canvas:
TextBlock TextBlock2= new TextBlock();
TextBlock2.FontSize = 24;
TextBlock2.Text = Raum.Text;
Canvas.SetTop(TextBlock2, 79);
Canvas.SetLeft(TextBlock2, 31);
myCanvas.Children.Add(TextBlock2);
第三:将第二个 TextBlock 添加到第二个 Canvas:
TextBlock TextBlock3 = new TextBlock();
TextBlock3.FontSize = 20;
TextBlock3.Text = Zeit;
Canvas.SetTop(TextBlock3, 36);
Canvas.SetLeft(TextBlock3, 10);
myCanvas2.Children.Add(TextBlock3);
将 myCanvas 和 myCanvas2 添加到 wrappanel:
wrapPanel.Children.Add(myCanvas);
wrapPanel.Children.Add(myCanvas2);
}
};
第一个 Canvas(myCanvas) 出现(框),但第二个 Canvas(myCanvas2) 没有出现(时间)。有人知道为什么吗?因为瓦帕内尔?