Note that there are some explanatory texts on larger screens.

plurals
  1. POIs there no simple way to set WPF StatusBar text?
    primarykey
    data
    text
    <p>I want to set the Text of a TextBlock in my StatusBar before making the user wait for a short moment while my program does a little bit of work.</p> <p>Aparently, instead of doing a nice little function like this (which does not work):</p> <pre><code>Function Load(ByVal Id As Guid) As Thing Cursor = Cursors.Wait TextBlockStatus.Text = "Loading..." TextBlockStatus.UpdateLayout() Dim Found = From t In db.Thing _ Where t.Id = Id _ Select t TextBlockStatus.Text = String.Empty Cursor = Cursors.Arrow Return Found End Function </code></pre> <p>I have to instead use this monstrosity:</p> <pre><code>Private WithEvents LoadWorker As BackgroundWorker Private Sub Window1_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded InitializeLoadWorker() End Sub Private Sub InitializeLoadWorker() LoadWorker = New BackgroundWorker LoadWorker.WorkerSupportsCancellation = False LoadWorker.WorkerReportsProgress = False AddHandler LoadWorker.DoWork, AddressOf LoadBackgroundWorker_DoWork AddHandler LoadWorker.RunWorkerCompleted, AddressOf LoadBackgroundWorker_RunWorkerCompleted End Sub Sub Load(ByVal Id As Guid) Cursor = Cursors.Wait LoadWorker.RunWorkerAsync(Argument) End Sub Private Sub LoadBackgroundWorker_DoWork(ByVal sender As Object, ByVal e As DoWorkEventArgs) Dim Worker As BackgroundWorker = DirectCast(sender, BackgroundWorker) Dim Id As Guid = DirectCast(e.Argument, Guid) e.Result = From t In db.Thing _ Where t.Id = Id _ Select t End Sub Private Sub LoadBackgroundWorker_RunWorkerCompleted(ByVal sender As Object, ByVal e As RunWorkerCompletedEventArgs) TextBlockStatus.Text = String.Empty Cursor = Cursors.Arrow Dim Found As Thing = DirectCast(e.Result, Thing) 'now do something with the found thing here instead of where Load() is called.' End Sub </code></pre> <p>And the Load() Function is now a Sub!!</p> <p>There must be a better way to handle such a simple situation. This doesn't need to be asynchronous.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload