Note that there are some explanatory texts on larger screens.

plurals
  1. POPulling data from Azure displaying on MainPage and ItemPage
    text
    copied!<p>I currently have the data for my application stored in an Azure Mobile Service SQL Database. I am pulling items from the database and displaying them in a List View. When a user clicks on an item in the list view they are then navigated to a new page that displays more details about the specific record from the database.</p> <p><strong>Main Page Code:</strong></p> <pre><code>public class OSVersions { [JsonProperty(PropertyName = "id")] public int id { get; set; } [JsonProperty(PropertyName = "Version")] public string Version { get; set; } [JsonProperty(PropertyName = "Codename")] public string Codename { get; set; } [JsonProperty(PropertyName = "Publish")] public bool Publish { get; set; } [JsonProperty(PropertyName = "ReleaseDate")] public DateTime ReleaseDate { get; set; } [JsonProperty(PropertyName = "Changes")] public string Changes { get; set; } [JsonProperty(PropertyName = "Notes")] public string Notes { get; set; } } public partial class OSMainVIew : PhoneApplicationPage { private MobileServiceCollection&lt;OSVersions, OSVersions&gt; items; private IMobileServiceTable&lt;OSVersions&gt; osTable = App.MobileService.GetTable&lt;OSVersions&gt;(); public OSMainVIew() { InitializeComponent(); } private async void RefreshOSItems() { progressBar1.IsEnabled = true; progressBar1.IsIndeterminate = true; items = await osTable .Where(OSItem =&gt; OSItem.Publish == true) .ToCollectionAsync(); MainListBox.ItemsSource = items; progressBar1.IsEnabled = false; progressBar1.Visibility = System.Windows.Visibility.Collapsed; progressBar1.IsIndeterminate = false; } protected override void OnNavigatedTo(NavigationEventArgs e) { RefreshOSItems(); } private void MainListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (MainListBox.SelectedIndex == -1) return; NavigationService.Navigate(new Uri("/ViewModels/OS/OSItemView.xaml?selectedItem=" + MainListBox.SelectedIndex, UriKind.Relative)); MainListBox.SelectedIndex = -1; } } </code></pre> <p><strong>Item Page Code:</strong></p> <pre><code>public partial class OSItemView : PhoneApplicationPage { private MobileServiceCollection&lt;OSVersions, OSVersions&gt; items; private IMobileServiceTable&lt;OSVersions&gt; osTable = App.MobileService.GetTable&lt;OSVersions&gt;(); public OSItemView() { InitializeComponent(); if ((Application.Current as App).IsTrial) { //textBlock1.Text = "Change Log available in full version only!"; //textBlock2.Visibility = System.Windows.Visibility.Collapsed; } } protected async override void OnNavigatedTo(NavigationEventArgs e) { string selectedIndex = ""; int buildID; int idValue; if (NavigationContext.QueryString.TryGetValue("selectedItem", out selectedIndex)) { //Start progressBar progressBar1.IsEnabled = true; progressBar1.IsIndeterminate = true; //Convert selectedIndex -&gt; buildID idValue = Convert.ToInt32(selectedIndex); buildID = idValue + 1; /* buildID = idValue + 1 becuase on OSMainView * Items stored in the ListBox are each even an index number * The first number is '0' * This is a problem because the first IDNumber in the Database is '1' * This isn't the best way to handle this, becuase even though the id field is an auto-increamental field, * sometimes values are skipped and rows are deleted. */ //Query database items = await osTable .Where(OSItem =&gt; OSItem.id == buildID) .ToCollectionAsync(); MainListBox.ItemsSource = items; //End progressBar progressBar1.IsEnabled = false; progressBar1.Visibility = System.Windows.Visibility.Collapsed; progressBar1.IsIndeterminate = false; } } } </code></pre> <p><strong>Items Page XAML Code:</strong></p> <pre><code>&lt;Grid x:Name="ContentPanel" Margin="10,97,12,0" Grid.RowSpan="2"&gt; &lt;ListBox x:Name="MainListBox" Margin="10,-35,-12,0"&gt; &lt;ListBox.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;StackPanel Margin="0,0,0,0" Width="432" Height="*"&gt; &lt;TextBlock TextWrapping="Wrap" Text="{Binding Version}" Style=" {StaticResource PhoneTextExtraLargeStyle}"/&gt; &lt;TextBlock Text="Notes" FontFamily="Segoe WP Bold" Foreground="{StaticResource PhoneAccentBrush}" Height="30" HorizontalAlignment="Left" Margin="0,1,0,0" Name="textBlock3" Padding="0" VerticalAlignment="Top" Width="444" /&gt; &lt;TextBlock x:Name="notesText" Text="{Binding Notes}" TextWrapping="Wrap" Style="{StaticResource PhoneTextNormalStyle}" Height="180" VerticalAlignment="Top" HorizontalAlignment="Stretch" FontFamily="Segoe WP SemiLight" Margin="0" Width="455"/&gt; &lt;TextBlock Text="Change Log" Height="30" HorizontalAlignment="Left" Margin="0,222,0,0" Name="textBlock1" VerticalAlignment="Top" FontFamily="Segoe WP Bold" Foreground="{StaticResource PhoneAccentBrush}" Width="444" Padding="0" /&gt; &lt;TextBlock Name="textBlock2" Text="{Binding Changes}" Style="{StaticResource PhoneTextNormalStyle}" TextWrapping="Wrap" Height="Auto" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" FontFamily="Segoe WP SemiLight" /&gt; &lt;/StackPanel&gt; &lt;/DataTemplate&gt; &lt;/ListBox.ItemTemplate&gt; &lt;/ListBox&gt; &lt;/Grid&gt; </code></pre> <p>My problem occurs when <code>MainListBox.ItemsSource = items;</code> is executed. The application quits without any error codes. </p> <p>Any ideas?</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