Search code examples
c#wpfcomboboxxceed

Xceed CheckComboBox not properly showing selected values from items hardcoded in XAML


I try to use a CheckComboBox control from the Xceed library.

When I select an item, the control displays system.windows.controls.comboxitem:"value" instead of just value

Is there a way to display only the value of the selected item without its type?

<xctk:CheckComboBox>
    <ComboBoxItem Content="SA" />
    <ComboBoxItem Content="NA" />      
</xctk:CheckComboBox>   

Solution

  • In this particular case it can be solved by adding the DisplayMemberPath="Content"

    <xctk:CheckComboBox DisplayMemberPath="Content">
        <ComboBoxItem Content="SA"/>
        <ComboBoxItem Content="NA"/>
    </xctk:CheckComboBox>
    

    But whether it is a designed feature or just a serendipitous behaviour, I am not sure.

    So overall it would be better in the future to read on WPF binding, and use datasources and bindings to make the code similar to what is on the documentation page.

    <xctk:CheckComboBox  
        DisplayMemberPath="Color"
        ValueMemberPath="Level"
        SelectedValue="{Binding SelectedValue}"
        SelectedItems="{Binding SelectedItems}" />