8,735
社区成员
发帖
与我相关
我的任务
分享
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApplication1"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525" >
<Grid>
<Button x:Name="button" Content="Button" HorizontalAlignment="Left" Margin="215,137,0,0" Click="button_Click"
VerticalAlignment="Top" Width="75"/>
</Grid>
</Window>
private void button_Click(object sender, RoutedEventArgs e)
{
Window1 w1 = new Window1();
w1.ShowDialog();
}
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApplication1"
mc:Ignorable="d"
Title="Window1" Height="300" Width="300">
<Grid>
</Grid>
</Window>
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApplication1"
mc:Ignorable="d"
Title="Window1" Height="300" Width="300">
<Grid>
<DataGrid Width="200" Height="200" Background="Brown">
</DataGrid>
</Grid>
</Window>
private void button_Click(object sender, RoutedEventArgs e)
{
Window1 w1 = new Window1();
w1.ShowDialog();
w1 = null;
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
}