'[Unknown]'属性不指向路径'(0)中的DependencyObject。(1)[1]。(2)'

时间:2013-05-05 06:16:55

标签: c# wpf wpf-controls prism

我不知道试图说什么是异常,我在论坛中搜索但仍然无法理解,所以在这里发布我的问题。

这是我的xaml

 <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);
        }            

btnSubjectSearch

当我点击“+”按钮时,它会弹出窗口并显示主题列表,但它会在“Application.Current.MainWindow.IsEnabled = false;”处抛出异常。

请有人指导我正确的道路,并提前致谢

0 个答案:

没有答案