Note that there are some explanatory texts on larger screens.

plurals
  1. POSet WPF Image source from List<T> based on combo box selection
    primarykey
    data
    text
    <p>I have a SearchResponse class that is returned to my viewmodel.</p> <pre><code>public class SearchResponse { public ICollection&lt;SearchResult&gt; Results { get; private set; } public string OriginalSearchTerm { get; private set; } public TimeSpan TimeTaken { get; private set; } public SearchResponse(ICollection&lt;SearchResult&gt; results, string originalSearchTerm, TimeSpan timeTaken) { Results = results; OriginalSearchTerm = originalSearchTerm; TimeTaken = timeTaken; } } </code></pre> <p>A listbox is bound to <code>SearchResponse.Results</code> with each item containing an image for the thumbnail. <code>SearchResult</code> looks like this:</p> <pre><code>public class SearchResult { public string Title { get; set; } public string Description { get; set; } public string Path { get; set; } public ICollection&lt;ThumbnailImage&gt; ThumbnailPaths { get; set; } public SearchResult() { } public SearchResult(string title, string description, string path, ICollection&lt;ThumbnailImage&gt; thumbnailPaths) { Title = title; Description = description; Path = path; ThumbnailPaths = thumbnailPaths; } } </code></pre> <p>And here is <code>ThumbnailImage</code> (ThumbnailSize is an enum):</p> <pre><code>public class ThumbnailImage { public int Id { get; set; } public ThumbnailSize ThumbnailSize { get; set; } public string Path { get; set; } public ThumbnailImage() { } public ThumbnailImage(ThumbnailSize thumbnailSize, string path) { ThumbnailSize = thumbnailSize; Path = path; } } </code></pre> <p>Finally, I have a ComboBox bound to an enum of thumbnail sizes with the intention that when the user selects a size the thumbnail images in the search results immediately change accordingly. So when this happens I need to query the <code>ICollection&lt;ThumbnailImage&gt;</code> for the correct filepath, update the image width and height (fixed width/height for each thumbnail size) and apply the changes to the entire list of results.</p> <pre><code>&lt;ComboBox DockPanel.Dock="Right" ItemsSource="{Binding Source={StaticResource ThumbnailSizesFromEnum}}" SelectedItem="{Binding CurrentThumbnailSize}"&gt; &lt;/ComboBox&gt; </code></pre> <p>I have a working bound <code>CurrentThumbnail</code> property as shown above.</p> <p>Can anyone suggest the best (or at least a good) way to approach this. At the moment I just have a headache form reading too much trying to find a solution. I wonder if I should make use of a Command, a Value Converter or maybe a StyleTrigger but either way I really need some pointers.</p> <p>Thanks.</p>
    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.
    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