Tuesday, 10 September 2013

Can't add textblock to Stackpanel Children

Can't add textblock to Stackpanel Children

I have the codes above which create a popup with a textblock, a progress
bar and a button programmatically then show. Progress bar and button were
ok but the textblock I added to stackpanel.children didnt show up. Anyone
have idea for this problem ? Thanks so much.
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;

No comments:

Post a Comment