in my MVVM application, I wish to create an auto-closing popup to notify some information to the users (for example "data changes saved successfully"). so, I placed a label into the form, bound to a VM property. Then, I wish to set my message and cancel it after a delay (1 second). But it seems not to work. the app just wait some time, and shows the final status (ie: when the user push "save" button, the app "waits" for one second, and then the label is empty). any ideas to get it? thanks
Asked
Active
Viewed 466 times
1
-
Have a look at this answer - you can tweak it slightly for your use case.https://stackoverflow.com/questions/51039348/show-current-time-wpf/51043116#51043116 – aydjay Jul 12 '18 at 15:37
-
2It probably doesn't work because you don't have any code. – Jul 12 '18 at 16:21
1 Answers
0
Why can't you use normal popup in WPF
<Popup Margin="10,10,0,13" Name="Popup1" HorizontalAlignment="Left" VerticalAlignment="Top" Width="194" Height="200" IsOpen="True">
<StackPanel>
<TextBlock Name="McTextBlock"
Background="LightBlue" >
This is popup text
</TextBlock>
<Button Content="This is button on a Pupup" />
</StackPanel>
public void show()
{
Popup1.IsOpen = true;
Thread t = new Thread(hide);
t.Start();
}
private void hide() {
Thread.Sleep(5000);
Popup1.IsOpen = false;
}
call show function when you want to show popup

RackM
- 449
- 7
- 26