-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…</p>

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)

4

1 回答 1

0

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

于 2012-08-16T10:29:39.627 回答