我不知道要说什么异常,我在论坛中搜索但仍然无法弄清楚,所以在这里发布我的问题。
这是我的xml
<StackPanel Orientation="Vertical"
Grid.Row="0"
Grid.Column="3"
Grid.RowSpan="3"
Style="{StaticResource ImageButtonContainer}">
<Button Name="btnSubjectSearch"
MinWidth="25"
Width="25"
Height="25"
HorizontalAlignment="Right"
Click="btnSubjectSearch_Click"
Visibility="{Binding SelectedProgram.IsProgramSelected, Mode=OneWay, Converter={StaticResource visibilityConverter}}"
Style="{StaticResource ImageButton}">
<Image Source="../Resources/blue_plus.png" HorizontalAlignment="Stretch" />
</Button>
<Button Name="btnRemoveSubject"
MinWidth="25"
Width="25"
Height="25"
HorizontalAlignment="Right"
Style="{StaticResource ImageButton}"
Click="btnRemoveSubject_Click">
<Image Source="../Resources/blue_minus.png" HorizontalAlignment="Stretch" />
</Button>
</StackPanel>
这是我背后的代码
private void btnSubjectSearch_Click(object sender, RoutedEventArgs e)
{
if (sender is Button)
{
**Application.Current.MainWindow.IsEnabled = false; //It throwing exception here**
(Application.Current.MainWindow as dynamic).ProcessWindowCloseability(false);
ShowPopup((Button)sender);
Model.SubjectSearchCommand.Execute(null);
}
当我单击“+”按钮时,它会弹出窗口并显示主题列表,但它会在“Application.Current.MainWindow.IsEnabled = false;”处引发异常。
请有人指导我正确的道路,并在此先感谢