0

I have a WPF Application with C#.

In this application there is a button which opens a new window/view. When this view opens it displays some data. At the same time new data is being retrieved and the view gets updated with this new data after a few seconds. I do not want the old data to be shown, so the view should just be loading until the new data is retrieved.

So I would like to have a loading modal (something like a pop-up) that is displayed in the middle of the screen until the data has been retrieved. Also the parent view should be frozen/disabled while loading the data.

My idea was to create a modal and open it (via .ShowDialog()) while the data is being retrieved. But when doing my research I found no possibility to automatically open the modal while the data is being retrieved. I only found how to open the modal via a button.

Does someone have an idea?

I basically just need a loading bar, but the loading bar should just be simple modal with just a small text (like "Wait till data is retrieved").

Enigmativity
  • 113,464
  • 11
  • 89
  • 172
MuriTuri
  • 7
  • 4
  • 1
    I would advice to check thread's. First you should use a thread to load the data besides the UI Thread, or it will block the UI Thread. Its a old topic but it will give you an idea https://stackoverflow.com/questions/3806535/wpf-loading-animation-on-a-separate-ui-thread-c – Camadas Aug 29 '22 at 09:35
  • That feature/control is often called "BusyIndicator": https://www.ecosia.org/search?method=index&q=wpf%20busyindicator – Stefan Wuebbe Aug 29 '22 at 09:41
  • Thank you very much for your comments, after doing additional research on the topics you've told me, I managed to get it working. Thanks again! – MuriTuri Aug 29 '22 at 09:55

1 Answers1

-1

I would recommend you to use SplashScreen, where you can show any picture at any time...

var splashScreen = new SplashScreen("load.png");
splashScreen.Show(false);

//data retrieve code here

splashScreen.Close(TimeSpan.FromSeconds(2));

You can make image out of any text using Photoshop or similar tools and use it as a 'Resource' in the WPF Project and then display it using the above code snippet...