Page 1 of 1

ComboBox with complex item

Posted: 14 Jul 2017, 00:30
by pbastia
Hi,

I am having trouble using the combobox in Unity3D, with more complex items (more than just a label or plain text). The selected object doesn't render in the main control, only in the expanding list.
Here is a little piece of sample code and the result:
<ComboBox Width="80" Height="40">
	<ComboBoxItem IsSelected="True">
		<StackPanel Orientation="Horizontal" Background="Yellow">
			<Label Content="123" Padding="6,4"/>
			<Label Content="123" Padding="6,4"/>
		</StackPanel>
	</ComboBoxItem>
	<ComboBoxItem>
		<StackPanel Orientation="Horizontal" Background="MediumPurple">
			<Label Content="456" Padding="6,4"/>
			<Label Content="456" Padding="6,4"/>
		</StackPanel>
	</ComboBoxItem>
	<ComboBoxItem>
		<StackPanel Orientation="Horizontal" Background="ForestGreen">
			<Label Content="789" Padding="6,4"/>
			<Label Content="789" Padding="6,4"/>
		</StackPanel>
	</ComboBoxItem>
</ComboBox>
Any Idea what I might be doing wrong?

Thanks a lot,

Result:
combo_open.png
combo_open.png (2.22 KiB) Viewed 1877 times
combo_closed.png
combo_closed.png (1.16 KiB) Viewed 1877 times

Re: ComboBox with complex item

Posted: 14 Jul 2017, 17:42
by pbastia
UPDATE: Noesis behaves properly when using templating.
<ComboBox Width="80" Height="40" ItemsSource="{Binding ComboItems}">
	<ComboBox.ItemTemplate>
		<DataTemplate>
			<Border Background="Yellow">
				<Label Content="{Binding}"/>
			</Border>
		</DataTemplate>
	</ComboBox.ItemTemplate>
</ComboBox>

Re: ComboBox with complex item

Posted: 14 Jul 2017, 18:37
by sfernandez
Yes, I've just looked at the code and it is not yet implemented. When items are UIElement the ComboBox.SelectionBoxItem property, used to render the selected item, is not correctly updated.
Could you please add this problem to the bugtracker?