RadMultiColumnComboBox textbox not cleared when SelectedItem is null (MVVM)

1 Answer 599 Views
MultiColumnComboBox
Roland
Top achievements
Rank 1
Roland asked on 02 Jun 2021, 06:48 PM

How do I clear the RadMultiColumnComboBox text when the SelectedItem value it is bound to is NULL?  The ComboBox retains the value of the previous selection.

SelectedItem="{Binding SelectedPricedLineItem.ManufacturingGroup, Mode=TwoWay}"
DisplayMemberPath="DisplayValue"

When  SelectedPricedLineItem.ManufacturingGroup is NULL, the value displayed is is from the previous LineItem

Setting SelectedIndex to -1 is not an option since that would break MVVM.

1 Answer, 1 is accepted

Sort by
0
Accepted
Dinko | Tech Support Engineer
Telerik team
answered on 07 Jun 2021, 08:40 AM

Hello Roland,

Thank you for the provided details.

I have tested your scenario, but I wasn't able to reproduce it. Can you confirm that your custom class is implementing the INotifyProperyChanged interface, and the property change method is called in the setter of custom property? If yes, may I ask you to share the set-up of the RadMultiColumnComboBox control? This way, I could try to build a project on my side and reproduce this.

Regards,
Dinko
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer, and each of you can get a $50 Amazon gift voucher.

Roland
Top achievements
Rank 1
commented on 08 Jun 2021, 06:28 PM | edited

Hi Dinko,

WPF R2 2021

I'm testing with your MultiColumnComboBox sample. Discovered that issue occurs when SelectionBoxesVisibility="Hidden" or when SelectionBoxesVisibility="Collapsed"

I want to dispaly text only; not selection boxes.

Maybe I'm encountering this issue...

https://feedback.telerik.com/wpf/1436800-radmulticolumncombobox-property-selectionboxesvisibility

Here's the Button code.

private void Button_Click(object sender, RoutedEventArgs e)
{
var vm = this.DataContext as ExampleViewModel;
vm.SelectedItem = null;
}

Thanks
Roland
Dinko | Tech Support Engineer
Telerik team
commented on 09 Jun 2021, 09:17 AM

It seems that it is related to the behavior described in the mentioned feedback item. I will also include your scenario so that our development team will include it for fixing while working on the main one. As a workaround, you can get the RadWatermarkTextBox control which holds the text, and manually reset its Text property when the selection is cleared.

You can get the control in the loaded event of the MCCB.

RadWatermarkTextBox inputWatermarkTextBox = null;
private void Mccb_Loaded(object sender, RoutedEventArgs e)
{
    inputWatermarkTextBox = this.mccb.ChildrenOfType<RadWatermarkTextBox>().FirstOrDefault(x=>x.Name == "WatermarkTextBox");
}

private void RadButton_Click(object sender, RoutedEventArgs e)
{
    var vm = this.DataContext as MainViewModel;
    vm.VM.SelectedItem = null;
    if(inputWatermarkTextBox != null)
    {
        inputWatermarkTextBox.Text = string.Empty;
    }
}

I hope this approach will work for you.

Roland
Top achievements
Rank 1
commented on 09 Jun 2021, 12:09 PM

Thank You Dinko. Your approach will work.
Tags
MultiColumnComboBox
Asked by
Roland
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or