Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>--- 1st try, ignore until '2nd try' --- Do not put the Image controls in the resource dictionary.</p> <p>If you have a fixed number of images, put them directly in your Window. E.g.:</p> <pre><code>&lt;Window&gt; &lt;StackPanel&gt; &lt;Image Source="{Binding Path=Image1}" /&gt; &lt;Image Source="{Binding Path=Image2}" /&gt; &lt;/StackPanel&gt; &lt;/Window&gt; </code></pre> <p>Then setup a class with the properties Image1 and Image2 mapping to the images coming from your DB and set an initialized instance of this class as the DataContext of your Window.</p> <p>More realistically, you have a variable number of images. The XAML becomes:</p> <pre><code>&lt;Window&gt; &lt;ItemsControl ItemsSource="{Binding Path=Components}"&gt; &lt;ItemsControl.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;Image Source="{Binding Path=Photo}" /&gt; &lt;/DataTemplate&gt; &lt;/ItemsControl.ItemTemplate&gt; &lt;ItemsControl&gt; &lt;/Window&gt; </code></pre> <p>And set the DataContext to an instance of ComponentsList.</p> <p>What you could put in the Resources dictionary is the item template. --- end of 1st try ---</p> <p>2nd try: After our comments exchange, the situation is that you have a template defined in the resource dictionary that you want to modify at run-time.</p> <p>It is necessary to wait that the template has been applied to your control hosting the images. It seems to a Toolbox class. I can't find it in the MSDN docs, so it looks custom, which is good as there is the OnApplyTemplate method where you get this information. If you can't modify this class, you can call ApplyTemplate() to be sure that the template is in place.</p> <p>Now you can use VisualTreeHelper.GetChild to look at the child controls in the template, in order to find the images of interest. In the example template, the images don't have a name attribute. If you can't have one added, you need to devise a strategy to recognize them, either by order or some other attributes, like the Tooltip.</p> <p>Once an image is found, you can set its properties as you like.</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