Browse Source

feat: respect DisplayMemberPath in SelectionBoxItem.

pull/11227/head
rabbitism 3 years ago
parent
commit
fb202aa060
  1. 17
      src/Avalonia.Controls/ComboBox.cs

17
src/Avalonia.Controls/ComboBox.cs

@ -443,7 +443,22 @@ namespace Avalonia.Controls
}
else
{
SelectionBoxItem = item;
if(ItemTemplate is null && DisplayMemberBinding is { } binding)
{
var template = new FuncDataTemplate<object?>((_, _) =>
new TextBlock
{
[TextBlock.DataContextProperty] = item,
[!TextBlock.TextProperty] = binding,
});
var text = template.Build(item);
SelectionBoxItem = text;
}
else
{
SelectionBoxItem = item;
}
}
}

Loading…
Cancel
Save