WPF Form is going behind all windows when a ComboBox is selected

11

My form WPF works perfectly, but in a specific%%, after the action of selecting, the form is going behind all windows without further explanation, and this does not happen in any other form, could anyone explain why?

The image before clicking on the ComboBox :

MyComboBox:

<ComboBoxName="CbAnimalSpecie" Grid.Column="1" Grid.Row="3" Height="25" Width="130" Margin="100,0,250,0" ItemsSource="{Binding Path=AnimalSpecies}" SelectedItem="{Binding Animal.AnimalSpecie}" SelectedValuePath="Id" DisplayMemberPath="Name">
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="SelectionChanged">
            <i:InvokeCommandAction Command="{Binding GetAllAnimalBreedsByAnimalSpecieCommand}" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
</ComboBox>

UPDATE

As requested, it follows my ComboBox processing:

protected Helper.Views.ProcessingView ShowProcessing(Window ownerView)
{
    try
    {
        var processingView = new Helper.Views.ProcessingView();

        processingView.Owner = ownerView;
        processingView.Show();

        ownerView.IsEnabled = false;

        return processingView;
    }
    catch (Exception)
    {
        throw;
    }
}

protected void CloseProcessing(Window ownerView, Window processingView)
{
    try
    {
        ownerView.IsEnabled = true;

        processingView.Hide();
        processingView.Close();
    }
    catch (Exception)
    {
        throw;
    }
}

My View :

public ICommand GetAllAnimalBreedsByAnimalSpecieCommand
{
    get { return _getAllAnimalBreedsByAnimalSpecieCommand ?? (_getAllAnimalBreedsByAnimalSpecieCommand = new DelegateCommand(GetAllAnimalBreedsByAnimalSpecie)); }
}

And finally, my method:

private void GetAllAnimalBreedsByAnimalSpecie()
{
    try
    {
        var processingView = base.ShowProcessing(this.AnimalUpdateView);

        this.AnimalBreedsOriginal = new Repository.AnimalBreed().GetAllAnimalBreeds();
        this.AnimalBreeds = new Repository.AnimalBreed().GetAllAnimalBreeds(T => T.AnimalSpecieId == this.Animal.AnimalSpecie.Id);

        base.CloseProcessing(this.AnimalUpdateView, processingView);
    }
    catch
    {
        throw;
    }
}

UPDATE 2

Okay, I found part of the Form problem, it's this code snippet:

private void GetAllAnimalBreedsByAnimalSpecie()
{
    try
    {
        var processingView = base.ShowProcessing(this.AnimalUpdateView);
        .
        .
        .

        base.CloseProcessing(this.AnimalUpdateView, processingView);
    }
    catch
    {
        throw;
    }
}

But as I said earlier, this section works perfectly on all software, because at that point it has this strange behavior?

    
asked by anonymous 23.12.2013 / 19:19

1 answer

6

Well, I found the part of the code that was giving trouble:

var processingView = new Helper.Views.ProcessingView();
processingView.Owner = null;
processingView.Show();
ownerView.IsEnabled = false;
return processingView;

For some strange reason, at the one time, described in the question above, the form would be backward if it had the property processingView.Owner filled, now, with it overridden, it works perfectly ...

    
26.12.2013 / 18:58