Native Window creation in code
- private void ButtonClick(object sender, RoutedEventArgs e)
- {
- if (!Application.Current.IsRunningOutOfBrowser)
- {
- return;
- }
- var newGrid = new Grid
- {
- Background = new SolidColorBrush(Colors.White),
- HorizontalAlignment = HorizontalAlignment.Stretch,
- VerticalAlignment = VerticalAlignment.Stretch
- };
- var newTextBlock = new TextBlock
- {
- HorizontalAlignment = HorizontalAlignment.Center,
- VerticalAlignment = VerticalAlignment.Center,
- Text = "New TextBlock in a new Window..."
- };
- newGrid.Children.Add(newTextBlock);
- new Window { Content = newGrid, Visibility = Visibility.Visible, Width = 300, Height = 300 };
- }
No comments:
Post a Comment