Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Compiled and tested solution.</p> <p>XAML:</p> <pre><code> &lt;ListBox x:Name="lb" ItemsSource="{Binding}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"&gt; &lt;ListBox.ItemContainerStyle&gt; &lt;Style TargetType="{x:Type ListBoxItem}"&gt; &lt;Setter Property="ToolTip"&gt; &lt;Setter.Value&gt; &lt;Image Stretch="UniformToFill" Source="{Binding ItemSymbol}" /&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; &lt;/ListBox.ItemContainerStyle&gt; &lt;ListBox.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;Label Grid.Column="1" Content="{Binding ItemName}"&gt; &lt;/Label&gt; &lt;/DataTemplate&gt; &lt;/ListBox.ItemTemplate&gt; &lt;/ListBox&gt; </code></pre> <p>Code:</p> <pre><code>using System; using System.Collections.Generic; using System.Windows; using System.Windows.Media.Imaging; namespace Test { public class ExpanderItem { private String mItemName = "empty"; public String ItemName { get { return mItemName; } set { mItemName = value; } } private BitmapImage mItemSymbol = null; public BitmapImage ItemSymbol { get { return mItemSymbol; } set { mItemSymbol = value; } } } public partial class MainWindow : Window { public MainWindow() { this.InitializeComponent(); lb.DataContext = this.getExpanderItems(); } public List&lt;ExpanderItem&gt; getExpanderItems() { List&lt;ExpanderItem&gt; ItemList = new List&lt;ExpanderItem&gt;(); ExpanderItem i0 = new ExpanderItem { ItemName = "Constant", ItemSymbol = new BitmapImage(new Uri(@"/resources/constant.png", UriKind.RelativeOrAbsolute)) }; ItemList.Add(i0); ExpanderItem i1 = new ExpanderItem { ItemName = "Constant", ItemSymbol = new BitmapImage(new Uri(@"/resources/constant.png", UriKind.RelativeOrAbsolute)) }; ItemList.Add(i1); return ItemList; } } } </code></pre>
 

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