-1

I created a pop-up and want to show it when a button has been clicked. But it doesn't work because it waits for finishing button's duty.

I don't want to use "timer, thread and background worker" because I already can do it with that. I am looking for an another solution…

Here is my code:

void btnSearch_Click(object sender, RoutedEventArgs e)
{
    LoadingOpen();

    if (cmbvideoserver.Text == "Youtube")
        SearchInYoutube();
    else if (cmbvideoserver.Text == "Vimeo")
        SearchInVimeo();

    LoadingClose();
}

public void LoadingOpen()
{
    myPopup.IsOpen = true;
    Common.Popup = true;
    window.Opacity = 0.3;
}

public void LoadingClose()
{
    myPopup.IsOpen = false;
    Common.Popup = false;
    window.Opacity = 1;
}

and the XAML:

<Window Name="window" x:Class="youtube.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525" Loaded="window_Loaded">
  <Canvas Name="main">
    <Popup Name="myPopup" IsOpen="False" PopupAnimation="Slide"
           Margin="100,10,20,0"  Placement="Center" >  
      <Label Content="Loading..."></Label>
    </Popup>
  </Canvas>
</Window>

How can I show popup on my main window ? (without any thread,timer and background controls/classes)

stakx - no longer contributing
  • 83,039
  • 20
  • 168
  • 268
unbalanced
  • 1,192
  • 5
  • 19
  • 44

1 Answers1

0

You can show Windows as dialogs by useing the ShowDialog() method.

Eirik
  • 4,135
  • 27
  • 29
  • but mypopup hasnt any kind of show methods.. ? and i think that if it even exists , the result will not be changed.. – unbalanced Aug 16 '12 at 10:35
  • Harun Abi - Did you mean that your Window doesnt have any ShowDialog() method???? Well, ideally speaking, it should have. – Sandeep Aug 16 '12 at 10:52