<DataGrid x:Name="dataGrid" ItemsSource="{Binding}">
<DataGrid.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="ToolTip">
<Setter.Value>
<ListBox ItemsSource="{Binding TestList}"></ListBox>
</Setter.Value>
</Setter>
</Style>
</DataGrid.CellStyle>
</DataGrid>
后台绑定:
this.Loaded += delegate
{
List<Demo> listDemo = new List<Demo>();
listDemo.Add(new Demo() { ID = 1, Name = "张三", Remark = "张三", TestList = new List<string>() { "A1", "B1", "C1" } });
listDemo.Add(new Demo() { ID = 2, Name = "李四", Remark = "李四", TestList = new List<string>() { "A2", "B2", "C2" } });
listDemo.Add(new Demo() { ID = 3, Name = "王五", Remark = "王五", TestList = new List<string>() { "A3", "B3", "C3" } });
dataGrid.DataContext = listDemo;
};public class Demo
{
public int ID { get; set; }
public string Name { get; set; }
public string Remark { get; set; }
public List<string> TestList { get; set; }
}本回答被提问者采纳