我有上面的代码,它以编程方式创建一个带有文本块、进度条和按钮的弹出窗口,然后显示。进度条和按钮没问题,但我添加到 stackpanel.children 的文本块没有显示。有人对这个问题有想法吗?非常感谢。
var tbInfo = new TextBlock {Text = "Checking... ", TextWrapping = TextWrapping.Wrap, Visibility = Visibility.Visible};
var mainPanel = new StackPanel {Background = new SolidColorBrush(Colors.Black)};
var popupBtnCancle = new Button {Content = "Cancel", Margin = new Thickness(3)};
popupBtnCancle.Click += new RoutedEventHandler(popupBtnCancle_Click);
var pbLoading = new ProgressBar
{
IsIndeterminate = true,
IsEnabled = true,
Visibility = Visibility.Visible,
};
mainPanel.Children.Add(tbInfo);
mainPanel.Children.Add(pbLoading);
mainPanel.Children.Add(popupBtnCancle);
border.Child = mainPanel;
_loading.Child = border;
_loading.VerticalOffset = 0;
_loading.HorizontalOffset = 0;
_loading.IsOpen = true;