最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - CheckCombobox Text property doesn't work when user checks items - Stack Overflow

programmeradmin9浏览0评论

Background

I'm learning C#, WPF and MVVM design pattern and I'm trying to create a window with some controls.

One of these controls is a CheckCombobox taken from Xceed's Extended WPF Toolkit.

In this control, the property SelectedItemsOverride holds a collection of all the checked items, and I'm binding a list called SelectedFilterParameters to this property

The Problem

When the dropdown of the control closes after the user checked some items, no text is generated from the checked items, that represents the checked items. Instead the the text stays empty while there are indeed checked items in the control.

Worth mentioning && what I've tried

  • Data bindings and functionality of the window works great
  • Property DisplayMemberPath="ValueToString" is correct. ValueToString is also being used in the <TextBlock> tag below which works properly
  • I also tried DisplayMemberPath="{Binding ValueToString}". Didn't work
  • I added a RaisePropertyChange() upon setting the checked items List which is bound to the control's SelectedItemsOverride property
  • ItemsSource="{Binding ParameterValueList... is just a list holding all the instances. Binds successfully

.cs from which the problematic List is being bound, Bindable Base:

private IList<ParameterValueData> selectedFilterParameters;

/// <summary>
/// Selected parameters values, selected by the user using checkbox, to assign to the filter later under OR rule.
/// </summary>
public IList<ParameterValueData> SelectedFilterParameters 
{
    get { return selectedFilterParameters; } 
    set 
    { 
        selectedFilterParameters = value;
        RaisePropertyChanged();
    } 
}

*.xaml part in which I'm binding:

<DataGridTemplateColumn Header="Multiple Selection ComboBox" Width="199">
     <DataGridTemplateColumn.CellTemplate>
          <DataTemplate>
                <xctk:CheckComboBox
                    ItemsSource="{Binding ParameterValueList, UpdateSourceTrigger=PropertyChanged}"
                    Delimiter=", "
                    Width="200"
                    SelectedItemsOverride="{Binding SelectedFilterParameters, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
                    DisplayMemberPath="ValueToString"
                     >
                    <xctk:CheckComboBox.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding ValueToString}"/>
                        </DataTemplate>
                    </xctk:CheckComboBox.ItemTemplate>
                </xctk:CheckComboBox>
            </DataTemplate>
        </DataGridTemplateColumn.CellTemplate>
    </DataGridTemplateColumn>
</DataGrid.Columns>

Illustration

Desired text outcome:

CON18+5 Plaster, CON18+7 Plaster, CON20+2 Plaster

发布评论

评论列表(0)

  1. 暂无评论