Note that there are some explanatory texts on larger screens.

plurals
  1. POwindows phone 7 progress bar for a listbox loading data
    primarykey
    data
    text
    <p>Is there an event I can listen for when a listbox has completed loading it's data? I have a textbox and a listbox, when the user hits enter, the listbox is populated with results from a web service. I'd like to run the progress bar while the listbox is loading and collapse it when it's finished....</p> <p><strong>UPDATE</strong></p> <pre><code> &lt;controls:PivotItem Header="food" Padding="0 110 0 0"&gt; &lt;Grid x:Name="ContentFood" Grid.Row="2" &gt; &lt;StackPanel&gt; ... ... &lt;toolkit:PerformanceProgressBar Name="ppbFoods" HorizontalAlignment="Left" VerticalAlignment="Center" Width="466" IsIndeterminate="{Binding IsDataLoading}" Visibility="{Binding IsDataLoading, Converter={StaticResource BoolToVisibilityConverter}}" /&gt; &lt;!--Food Results--&gt; &lt;ListBox x:Name="lbFoods" ItemsSource="{Binding Foods}" Padding="5" SelectionChanged="lbFoods_SelectionChanged" Height="480" &gt; .... &lt;/ListBox&gt; &lt;/StackPanel&gt; &lt;/Grid&gt; &lt;/controls:PivotItem&gt; </code></pre> <p>Here is my helper converter class....</p> <pre><code> public class BoolToValueConverter&lt;T&gt; : IValueConverter { public T FalseValue { get; set; } public T TrueValue { get; set; } public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value == null) return FalseValue; else return (bool)value ? TrueValue : FalseValue; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return value != null ? value.Equals(TrueValue) : false; } } public class BoolToStringConverter : BoolToValueConverter&lt;String&gt; { } public class BoolToBrushConverter : BoolToValueConverter&lt;Brush&gt; { } public class BoolToVisibilityConverter : BoolToValueConverter&lt;Visibility&gt; { } public class BoolToObjectConverter : BoolToValueConverter&lt;Object&gt; { } </code></pre> <p>In my App.xaml....</p> <pre><code> xmlns:HelperClasses="clr-namespace:MyVirtualHealthCheck.HelperClasses" ... &lt;HelperClasses:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" TrueValue="Visible" FalseValue="Collapsed" /&gt; </code></pre> <p>The viewModel....</p> <pre><code> ... public bool IsDataLoading { get; set; } ... public void GetFoods(string strSearch) { IsDataLoading = true; WCFService.dcFoodInfoCollection localFoods = IsolatedStorageCacheManager&lt;WCFService.dcFoodInfoCollection&gt;.Retrieve("CurrentFoods"); if (localFoods != null) { Foods = localFoods; } else { GetFoodsFromWCF(strSearch); } } public void GetFoodsFromWCF(string strSearch) { IsDataLoading = true; wcfProxy.GetFoodInfosAsync(strSearch); wcfProxy.GetFoodInfosCompleted += new EventHandler&lt;WCFService.GetFoodInfosCompletedEventArgs&gt;(wcfProxy_GetFoodInfosCompleted); } void wcfProxy_GetFoodInfosCompleted(object sender, WCFService.GetFoodInfosCompletedEventArgs e) { WCFService.dcFoodInfoCollection foods = e.Result; if (foods != null) { //set current foods to the results from the web service this.Foods = foods; this.IsDataLoaded = true; //save foods to phone so we can use cached results instead of round tripping to the web service again SaveFoods(foods); } else { Debug.WriteLine("Web service says: " + e.Result); } IsDataLoading = false; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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