Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do i handle an exception caused by XAML binding to a static instance property SQL timeout?
    text
    copied!<p>I have problem where after loading my app, sometimes my connection to SQL is dropped. This often results in an error because i have a combobox's itemsource bound to a separate static class property that, inside the GET of the property, queries SQL. I can't seem to handle the exception inside the Get. How should I do this, or is querying SQL in the Get of the static property I'm binding to not the way to go? The GetFrequencies method is in the same static class as the static property, and just queries some stuff from SQL and throws an exception if it can't connect etc. Here's the basic property and binding: Property in static class (an instance):</p> <pre><code>public ObservableCollection&lt;Frequency&gt; ActiveFrequencies { get { ObservableCollection&lt;Frequency&gt; Actives = new ObservableCollection&lt;Frequency&gt;(); try { foreach (Frequency item in GetFrequencies(null, null, true)) { Actives.Add(item); } } catch (Exception e) { } return Actives; } } </code></pre> <p>Binding in XAML:</p> <pre><code>ItemsSource="{Binding ActiveFrequencies, Source={x:Static G:FrequencyData.Instance}}" </code></pre> <p>okay so i made a property inside my viewmodel instead:</p> <pre><code>public ObservableCollection&lt;Frequency&gt; ActiveFrequencies { get { ObservableCollection&lt;Frequency&gt; freqs = null; try { freqs = FrequencyData.Instance.GetFrequencies(null, null, true); } catch(Exception ex) { } return freqs; } } </code></pre> <p>but i stil can't really shutdown the app in the Catch block, it seems to go on to other properties first. this is a viewmodel for a user control that is inside a main application view model. do i need to message my main view model to shutdown instead?</p>
 

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