嘿,我正在尝试使用以下代码向我的网格添加标签:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click
Dim dynamicLabel As New Label()
Dim g As New Grid
dynamicLabel.Name = "NewLabel"
dynamicLabel.Content = "TEST"
dynamicLabel.Width = 240
dynamicLabel.Height = 30
dynamicLabel.Margin = New Thickness(0, 21, 0, 0)
dynamicLabel.Foreground = New SolidColorBrush(Colors.White)
dynamicLabel.Background = New SolidColorBrush(Colors.Black)
Grid.SetRow(dynamicLabel, 0)
Grid.SetColumn(dynamicLabel, 6)
g.Children.Add(dynamicLabel)
End Sub
但是,按下按钮后,我再也看不到网格上的任何东西......我错过了什么?