예제 #1
0
        private void cbDistinctProperties_DropDownOpened(object sender, EventArgs e)
        {
            if (_boundColumnPropertyAccessor != null)
            {
                DistinctPropertyValues.Clear();
                //if (DistinctPropertyValues.Count == 0)
                //{
                List <object> result = new List <object>();
                foreach (var i in Grid.ItemsSource)
                {
                    object value = _boundColumnPropertyAccessor(i);
                    if (value != null)
                    {
                        if (result.Where(o => o.ToString() == value.ToString()).Count() == 0)
                        {
                            result.Add(value);
                        }
                    }
                    else if (FilterColumnInfo.PropertyType == typeof(bool?) && FilterColumnInfo.IsSpecialState)
                    {
                        if (result.Where(o => o == value).Count() == 0)
                        {
                            result.Add(value);
                        }
                    }
                }
                try
                {
                    result.Sort();
                }
                catch
                {
                    if (System.Diagnostics.Debugger.IsLogging())
                    {
                        System.Diagnostics.Debugger.Log(0, "Warning", "There is no default compare set for the object type");
                    }
                }

                foreach (var obj in result)
                {
                    var item = new CheckboxComboItem()
                    {
                        Description = GetFormattedValue(obj),
                        Tag         = obj,
                        IsChecked   = true
                    };
                    item.PropertyChanged += new PropertyChangedEventHandler(filter_PropertyChanged);
                    DistinctPropertyValues.Add(item);
                }
                //}
            }
        }
예제 #2
0
        private void cbDistinctProperties_DropDownOpened(object sender, EventArgs e)
        {
            if (_boundColumnPropertyAccessor != null)
            {
                if (FilterSelectedItem.BoolPropertyValues.Count == 0)
                {
                    List <object> result = new List <object>();
                    foreach (var i in FilterSelectedItem.Grid.ItemsSource)
                    {
                        AllSelectedPropertyChanged selectedModel = i as AllSelectedPropertyChanged;
                        object value = _boundColumnPropertyAccessor(selectedModel);
                        if (value != null)
                        {
                            if (result.Where(o => o.ToString() == value.ToString()).Count() == 0)
                            {
                                result.Add(value);
                            }
                        }
                        else if (FilterColumnInfo.PropertyType == typeof(bool?) && FilterColumnInfo.IsSpecialState)
                        {
                            if (result.Where(o => o == value).Count() == 0)
                            {
                                result.Add(value);
                            }
                        }
                    }
                    try
                    {
                        result.Sort();
                    }
                    catch
                    {
                        if (System.Diagnostics.Debugger.IsLogging())
                        {
                            System.Diagnostics.Debugger.Log(0, "Warning", "There is no default compare set for the object type");
                        }
                    }

                    foreach (var obj in result)
                    {
                        var item = new CheckboxComboItem()
                        {
                            Description = GetFormattedValue(obj),
                            Tag         = obj
                        };
                        FilterSelectedItem.BoolPropertyValues.Add(item);
                    }
                }
            }
        }