Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>After a quick test your code seems to work fine.</p> <p>My test:</p> <p>xaml:</p> <pre><code> &lt;Window x:Class="WpfApplication4.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:WpfApplication4" xmlns:Controls="clr-namespace:Liz.Common" Title="MainWindow" Height="300" Width="400" Name="UI" &gt; &lt;Window.Resources&gt; &lt;DataTemplate x:Key="removableTalentListTemplate"&gt; &lt;StackPanel&gt; &lt;TextBlock FontSize="13" Text="{Binding Path=tName}" VerticalAlignment="Center" Width="175" Height="18" Grid.Column="0" &gt; &lt;TextBlock.ToolTip&gt; &lt;ToolTip Background="Blue"&gt; &lt;StackPanel&gt; &lt;TextBlock Text="{Binding Path=Description}" Foreground="White" /&gt; &lt;/StackPanel&gt; &lt;/ToolTip&gt; &lt;/TextBlock.ToolTip&gt; &lt;/TextBlock&gt; &lt;/StackPanel&gt; &lt;/DataTemplate&gt; &lt;/Window.Resources&gt; &lt;Grid&gt; &lt;ListBox ItemTemplate="{StaticResource removableTalentListTemplate}" ItemsSource="{Binding ElementName=UI, Path=Models}" /&gt; &lt;/Grid&gt; &lt;/Window&gt; </code></pre> <p>Code:</p> <pre><code>public partial class MainWindow : Window { private ObservableCollection&lt;MyModel&gt; _models = new ObservableCollection&lt;MyModel&gt;(); public MainWindow() { InitializeComponent(); Models.Add(new MyModel { tName = "Test", Description = "Hello" }); } public ObservableCollection&lt;MyModel&gt; Models { get { return _models; } set { _models = value; } } } public class MyModel : INotifyPropertyChanged { private string _tName; private string _description; public string tName { get { return _tName; } set { _tName = value; NotifyPropertyChanged("tName"); } } public string Description { get { return _description; } set { _description = value; NotifyPropertyChanged("Description"); } } public event PropertyChangedEventHandler PropertyChanged; private void NotifyPropertyChanged(string property) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(property)); } } } </code></pre> <p>result: <img src="https://i.stack.imgur.com/QOlK4.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    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