/// <summary> /// Helper method which turns the SQL dataset into the list displayed in the UI. /// </summary> /// <param name="routerDS">The SQL dataset gotten from the Routers table</param> private void initalizeRouterList(DataSet routerDS) { DataRow routerDR; // covert each data row into a new RouterData object numRows = routerDS.Tables[0].Rows.Count; RouterData[] routerDataArray = new RouterData[numRows]; for (int i = 0; i < numRows; i++) { //get all 5 columns which are used in UI from the data set routerDR = routerDS.Tables[ROUTER_TABLE].Rows[i]; routerDataArray[i] = new RouterData { Brand = routerDR.ItemArray.GetValue(ROUTER_BRAND).ToString(), ImageData = LoadImage(routerDR.ItemArray.GetValue(ROUTER_IMAGE).ToString()), Model = routerDR.ItemArray.GetValue(ROUTER_MODEL).ToString(), Price = this.getPrice(routerDR.ItemArray.GetValue(ROUTER_ITEM_ID).ToString()), URL = this.getURL(routerDR.ItemArray.GetValue(ROUTER_ITEM_ID).ToString()) }; } // set the WPF list to the array of router data objects RouterList.ItemsSource = routerDataArray; this.routerData = routerDataArray; }
/// <summary> /// Button listener for when an item in the router list is clicked /// The selected item will then be stored in the Appilcation-Scope Properties. /// </summary> /// <param name="sender">object which the event came from</param> /// <param name="e">Extra arguments from the event, not used here</param> private void RouterItem_MouseUp(object sender, MouseButtonEventArgs e) { RouterData routerData = RouterList.SelectedItem as RouterData; Application.Current.Properties["SelectedRouter"] = routerData.Model; // go to the main page this.NavigationService.Navigate(new Uri("MainPage.xaml", UriKind.Relative)); }