We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

ComboboxAdv and CheckBox. SelectedItems don't work.

Hello
I have a problem with CombobBox.
In my ComboBox I want have Items as CheckBox and text. I want use this solutin in WPF application with MVVM Light.

This is my code:

View:
            <syncfusion:ComboBoxAdv
                Margin="10,0,10,0"
                Grid.Column="0"
                Grid.ColumnSpan="3"
                FontSize="15"
                AllowMultiSelect="True"
                SelectedItems="{Binding SelectedDataGridColumns, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                ItemsSource="{Binding DataGridColumn, Mode=TwoWay}"/>
----------------------------------------------------------------------------------------------------------------------------------------------

ViewModel:
 public class ListUsersViewModel : ViewModelBase
 {
private ObservableCollection selectedDataGridColumns;

public ObservableCollection SelectedDataGridColumns
{
get { return selectedDataGridColumns; }
set
{
if (value.Count() != 0)
{
Set(ref selectedDataGridColumns, value);

ShowDataGridColumn(); // my method which sets the visibility of columns
}
}
}


private ObservableCollection dataGridColumn;

public ObservableCollection DataGridColumn
{
get { return dataGridColumn; }
set
{
Set(ref dataGridColumn, value);
}
}

public ListUsersViewModel()
{
            DataGridColumn = new ObservableCollection<string>()
            {
"a",
"b",
"c"
            };

            SelectedDataGridColumns = new ObservableCollection<object>()
            {
                "a",
                "c"
            }
}

public void ShowDataGridColumn()
{
  // When the SelectedDataGridColumns will be changing I want call the this method
}
}

----------------------------------------------------------------------------------------------------------------------------------------------

I set break Point in SelectedDataGridColumns (set) and run my application. 

SelectedDataGridColumns (set) is call twice:
1. When value.Count is = 2
2. When value.Count is = 0
and finaly SelectedDataGridColumns in ComboBox is 0 (This is ine problem)

A second problem:
When I selected item with ComboBox program go to SelectedDataGridColumns (set) and value = NULL
When I selected item second time with ComboBox program doing nothing,  don't enter to SelectedDataGridColumns (set)

This solution don't work, The same problems.
https://www.syncfusion.com/kb/5792/how-to-select-items-from-comboboxadv-control-at-startup

Pleace help me :)


5 Replies

KJ Keerthana Jegannathan Syncfusion Team August 29, 2016 12:45 PM UTC

Hi Konrad, 
 
Thank you for contacting Syncfusion support. 
 
In ComboBoxAdv, SelectedItems are binded as collection object. Hence, we request you to use the CollectionChanged event of the Binding source . This event is hooked after each update to the ComboBoxAdv. Please refer to the below code sample. 
 
 
Please let us know, if it helps. 
 
Regards, 
Keerthana J 



UN Unknown August 30, 2016 10:12 AM UTC

This solution help me, Thank You :)

ButI have other problems

1. How can I change "DefaultText"? Default when I selected items "DefaultText" is a name selected items with Delimiter e.g. I selected "a" and "d". Now Default text is "a-d". I want to have a fixed text e.g. "Selected Items...".

2. How change text when in control I do AllowSelectAll="True" ? Default text is "Select all"

Thanks for help :)


KJ Keerthana Jegannathan Syncfusion Team August 31, 2016 10:20 AM UTC

Hi Konrad,   
   
In ComboBoxAdv, Default text gets displayed only when none of the item is selected. It is used to provide message before selecting the item. Once the item is selected then the default text will be cleared and selected item will get displayed. This is default behavior of the ComboBoxAdv. Can you share more information about your requirement and it would help to provide the solution at earliest?   
   
Regards,   
Keerthana J     



UN Unknown August 31, 2016 12:23 PM UTC

Ok. Sorry for my English :)

This is image with show my problems:
https://s10.postimg.io/8yqab7cll/Bez_tytu_u.png

[1] - I solved this problem by modifying the style ComboBox Adv with this topic:
https://www.syncfusion.com/forums/125423/comboboxadv-change-background-when-i-want-select-item-and-when-i-clicked-on-comboboxadv

[2] - Sorry for the Polish name but my program is in Polish.  I want have "Selected items..." all time, regardless of whether I choose the item.

[3] - When I clic "select all" I have "Bacground=blue". How change this color, because style with topic:
https://www.syncfusion.com/forums/125423/comboboxadv-change-background-when-i-want-select-item-and-when-i-clicked-on-comboboxadv
don't include the background settings when I set "AllowSelectAll=True" in ComboBoxAdv in xaml file. I heave change color when I click "Select all" and when I invade muose, this is: 
IsPressed Trigger,
IsMouseOver Trigger,
IsChecked Trigger.

Regards, 
Konrad D 



KJ Keerthana Jegannathan Syncfusion Team September 1, 2016 03:08 PM UTC

Hi Konard, 
 
We have prepared sample in which we had updated the DefaultText on loading and when the ComboBoxAdv lost focus and also we have modified the text from in SelectAll to Select in App.Xaml file when binding content to the AllowSelectAll property.  
 
Currently we are preparing the sample for your remaining, we will update you the sample soon. 
 
Regards, 
Keerthana J 


Loader.
Up arrow icon