我正在开发 Silverlight 应用程序。我正在使用 silverlight 中的 itemscontrols 根据要求调整 UI。
<ItemsControl x:Name="CertificationsAndLicensesItemsControl">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid Grid.Row="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid Grid.Row="0" Grid.Column="0" Width="500">
<TextBlock TextWrapping="Wrap" Foreground="Green" Text="{Binding Path=CertificationsAndLicensesTitle}" FontWeight="Bold" Margin="5"></TextBlock>
</Grid>
<Grid Grid.Row="0" Grid.Column="1">
<StackPanel Orientation="Horizontal">
<TextBlock FontWeight="Bold" Text="Valid from:" HorizontalAlignment="Left" Margin="5"></TextBlock>
<TextBlock Text="{Binding Path=ValidFrom}" Margin="5" ></TextBlock>
<TextBlock Text="Until" Margin="5"></TextBlock>
<TextBlock Text="{Binding Until}" Margin="5"></TextBlock>
</StackPanel>
</Grid>
<Grid Grid.Row="1" Grid.ColumnSpan="2">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="5">
<Button x:Name="EditButton" Tag="{Binding Path=ID}" Content="Edit" Click="EditButton_Click"></Button>
<Button x:Name="DeleteButton" Tag="{Binding Path=ID}" Content="Delete" Click="DeleteButton_Click"></Button>
</StackPanel>
</Grid>
</Grid>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
后面的代码如下
private void EditButton_Click(object sender, RoutedEventArgs e)
{
//int a = 10;
//CertificationsAndLicensesChildWindow obj = new CertificationsAndLicensesChildWindow();
//obj.Show();
ChildWindow1 obj1 = new ChildWindow1();
obj1.Show();
}
private void DeleteButton_Click(object sender, RoutedEventArgs e)
{
CertificationsAndLicensesChildWindow obj = new CertificationsAndLicensesChildWindow();
obj.Show();
}
单击按钮时不会显示子窗口。单击按钮后,整个用户界面消失。如果我删除以下句子
ChildWindow1 obj1 = new ChildWindow1();
obj1.Show();
然后至少断点被击中。如果我保持上述句子不变,那么断点就不会被击中。如何在按钮单击时显示子窗口?您能否提供我可以解决上述问题的任何代码或链接