pbastia
Topic Author
Posts: 14
Joined: 15 May 2017, 19:19

ComboBox with complex item

14 Jul 2017, 00:30

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 1011 times
combo_closed.png
combo_closed.png (1.16 KiB) Viewed 1011 times
 
pbastia
Topic Author
Posts: 14
Joined: 15 May 2017, 19:19

Re: ComboBox with complex item

14 Jul 2017, 17:42

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>
 
User avatar
sfernandez
Site Admin
Posts: 1918
Joined: 22 Dec 2011, 19:20

Re: ComboBox with complex item

14 Jul 2017, 18:37

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?

Who is online

Users browsing this forum: No registered users and 1 guest