Mark
Topic Author
Posts: 4
Joined: 20 Apr 2021, 18:52

Using non ComboBoxItem in ComboBox

13 Oct 2021, 18:31

Hi,
I'm trying to use a control other than a ComboBoxItem in a ComboBox control.
It appears in the drop down list fine.
Problem is it does not appear when selected.
Works fine in WPF (anything seems to work in fact, TextBlock, etc. but not in Noesis).

Is this a limitation or possibly something I might be doing wrong?

I could post some sample XAML if needed, but wanted to see if it was something known first.
 
User avatar
sfernandez
Site Admin
Posts: 2983
Joined: 22 Dec 2011, 19:20

Re: Using non ComboBoxItem in ComboBox

13 Oct 2021, 19:14

There is a known issue about that: #1125.
The problem can be avoided by using data binding and a data template for the item.
<Grid>
  <Grid.Resources>
    <DataTemplate x:Key="itemTemplate">
      <StackPanel Orientation="Horizontal">
        <Rectangle Width="20" Fill="{Binding Fill}"/>
        <Button Content="..." Margin="5,0" Padding="5,0"/>
        <TextBlock Text="{Binding Name}" VerticalAlignment="Center"/>
      </StackPanel>
    </DataTemplate>
  </Grid.Resources>
  <ComboBox ItemsSource="{Binding Items}" ItemTemplate="{StaticResource itemTemplate}"/>
</Grid>
Can that work for you?
 
Mark
Topic Author
Posts: 4
Joined: 20 Apr 2021, 18:52

Re: Using non ComboBoxItem in ComboBox

13 Oct 2021, 19:26

Ah, that's a shame. Thanks for posting an alternative, I'll have a play with that and get back to you.

Who is online

Users browsing this forum: Google [Bot] and 83 guests