MainWindow.xaml
<Window xClass="HelloWorld.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlnsx="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="200" Width="300">
<StackPanel>
<Button Click="ShowMethod">Show</Button>
<Button Click="UseVisibilityProperty">Visible</Button>
<Button Click="ShowDialogMethod">ShowDialog</Button>
</StackPanel>
</Window>
MainWindow.xaml.cs
using System.Windows;
namespace HelloWorld {
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
}
private void ShowMethod(object sender, RoutedEventArgs e) {
Window w = new Window();
w.Title = "Show";
w.Height = 200;
w.Width = 300;
w.Show();
}
private void UseVisibilityProperty(object sender, RoutedEventArgs e) {
Window w = new Window();
w.Title = "Visiblity = Visible";
w.Height = 200;
w.Width = 300;
w.Visibility = Visibility.Visible;
}
private void ShowDialogMethod(object sender, RoutedEventArgs e) {
Window w = new Window();
w.Title = "ShowDialog";
w.Owner = this;
w.WindowStartupLocation = WindowStartupLocation.CenterOwner;
w.ShowInTaskbar = false;
w.Height = 200;
w.Width = 300;
w.ShowDialog();
}
}
}
アプリ実行