private void imageListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { foreach (object item in e.AddedItems) { try { WallpaperDTO wp = (WallpaperDTO)item; SetImage(wp.WallpaperContent); } catch (Exception ex) { logTextBoxAdd(ex.Message); } } }
private void setWallpaper_Click(object sender, RoutedEventArgs e) { if (imageListBox.SelectedItem == null) { logTextBoxAdd("Please select an image"); return; } WallpaperDTO wp = (WallpaperDTO)imageListBox.SelectedItem; HttpResponseMessage httpResult = client.PutAsync($"/api/wallpaper/{wp.Id}", new StringContent(string.Empty)).Result; if (httpResult.IsSuccessStatusCode) { logTextBoxAdd("Wallpaper Request succeeded"); } else { logTextBoxAdd("Wallpaper Request failed"); } }