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:
和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)
如何在主窗口上显示弹出窗口? (没有任何线程,计时器和后台控件/类)
1 个解决方案
#1
0
You can show Windows as dialogs by useing the ShowDialog() method.
您可以使用ShowDialog()方法将Windows显示为对话框。
#1
0
You can show Windows as dialogs by useing the ShowDialog() method.
您可以使用ShowDialog()方法将Windows显示为对话框。