Page 1 of 1

Using non ComboBoxItem in ComboBox

Posted: 13 Oct 2021, 18:31
by Mark
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.

Re: Using non ComboBoxItem in ComboBox

Posted: 13 Oct 2021, 19:14
by sfernandez
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?

Re: Using non ComboBoxItem in ComboBox

Posted: 13 Oct 2021, 19:26
by Mark
Ah, that's a shame. Thanks for posting an alternative, I'll have a play with that and get back to you.