WPF form is going behind all windows when a Combobox is selected

Asked

Viewed 286 times

11

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

The image before clicking on ComboBox:

A imagem antes de clicar no <code>ComboBox</code>

My ComboBox:

<ComboBox Name="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>

UPDATING

As requested, follow my View 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;
    }
}

Man Command:

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 snippet of code:

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

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

But as I said earlier, this chunk works perfectly on all the software, because right now it has this strange behavior?

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 single moment, described in the question above, the form would go back to everything if it were with the property processingView.Owner filled, now, with it annulled, works perfectly...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.