Current filter:
                                You should refresh the page.
                                  • Hey all,

                                    Sorry to bother once again, but I am trying to figure out how to have "OnPropertyChanged" event fire when a user selects the default value provided by the "ShowCustomItemns" property.

                                    Xaml,

                                    [XAML]
                                    <dxe:ComboBoxEdit Width="120" ItemsSource="{Binding ReportViewModel.CustomCostFilterList, Mode=TwoWay}" SelectedItem="{Binding ReportViewModel.CustomCostFilterOne, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay, ValidatesOnDataErrors=True}" DisplayMember="Key" ValueMember="Value" ShowError="False" ShowCustomItems="True" ValidateOnTextInput="False" NullText="フィルター選択"> </dxe:ComboBoxEdit>

                                    And C#,

                                    [C#]
                                    private KeyValuePair<string, string> _customCostFilterOne; public KeyValuePair<string, string> CustomCostFilterOne { get => _customCostFilterOne; set { if (Equals(value, _customCostFilterOne)) return; _customCostFilterOne = value; OnPropertyChanged(); } }

                                    Again, any push in the right direction would be great.

                                    Cheers Dave

                                • Alexander Rus (DevExpress Support) 08.13.2019

                                  Hi Dave,
                                  Do you mean that the OnPropertyChanged method is not called when you select the "None" item? If so, it's strange because as stated in the ShowCustomItemns" help topic, selecting the "None" item should clear the editor value and as a result its selected item should be set to null. I created a test project and it seems that ComboBoxEdit properly updates the property bound to SelectedItem when "None" is selected. Please check the project on your side and let me know if I missed any important details. I also suggest that you add a breakpoint to the CustomCostFilterOne property setter in your project to ensure that it's properly called when you select different ComboBoxEdit items.

                                  Thanks,
                                  Alexander

                                • JapanDave 08.13.2019

                                  Hey Alexander,

                                  Yes, OnPropertyChanged method is not called when the SelectedItem is "None". The reason why I know the method is not called is b/c I need to save the values to user settings, so when other items are selected the method is called and I can perform the logic needed. So to answer your question, yes the OnPropertyChanged method is called when selecting other items.

                                  I redid your example as to how I am setting up the ComboxEdit, and I am able to reproduce the same results as I am getting. See attached.
                                  One thing I noticed when selecting "None" on a KeyValuePair is you get a DataValidation error. Maybe, you can't use KeyValuePairs for comboBoxes?

                                  I would love to know what the issue is if you do find out, but for now I created a custom class with two string properties and it is working for me.

                                  Cheers Dave

                                1 Solution

                                Creation Date Importance Sort by

                                Hello,

                                Thank you for your update.

                                When you select the (none)  item, the editor's EditValue is set to Null. Your SelectedCustomer property, in turn, is of the KeyValuePair<string, string>  data type. This type is a struct and cannot be Null. That is why you see this validation error and cannot clear a value in your editor.
                                I suggest you thoroughly review this MSDN help topic: Structs (C# Programming Guide). As described there, you need to make this property of the nullable type (see Nullable Types):

                                [C#]
                                KeyValuePair<string, string>? selectedCustomer; public KeyValuePair<string, string>? SelectedCustomer { get { return selectedCustomer; } set { selectedCustomer = value; //Debug.WriteLine(value == null ? "null" : value.Name); } }

                                Please try this and let me know your results.

                                Thanks,
                                Andrey

                                • JapanDave 08.14.2019

                                  Hey Andrey,

                                  As I stated in my last comment, I have created a class with two string properties and I got it working.

                                  Thanks for the links, I did not know that structs are not allowed to be null, another thing learned.

                                  Cheers and thanks for all the help as always.
                                  Dave

                                • Andrey Marten (DevExpress Support) 08.14.2019

                                  I'm happy to hear that this issue is now resolved. Thank you for keeping us informed.

                                  Andrey