コード例 #1
0
        /*
         * --------------------------------------------------------------------------------------------------------
         *  Excel AutoFilter works as follows:
         *  For a specific column, it shows all the possible values in that column,
         *  given the rest of the column filters as set (but not the current column one)
         * --------------------------------------------------------------------------------------------------------
         */
        void dataGrid_FilterOpened(object sender, DataGridColumnValueEventArgs <IDataGridFilter> e)
        {
            var boundColumn = e.Column as C1.WPF.DataGrid.DataGridBoundColumn;

            if (boundColumn == null)
            {
                return;
            }

            // get source values that satisfies all the rest of the filters
            var items = AutoFilterHelper.GetAutoFilterValues(PersonInfo.All, boundColumn);

            // get the distinct values for THIS column
            var currentColumnPath = boundColumn.Binding.Path.Path;
            var selector          = C1PropertyPathHelper.CreateSelector <PersonInfo, object>(currentColumnPath);

            // create and set multi-value filter control into the column
            var filterControl = (DataGridMultiValueFilter)((DataGridFilter)e.Value).InnerControl;

            filterControl.ItemsSource = items.Select(selector).Distinct().OrderBy(o => o);
        }
コード例 #2
0
        public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var selector = C1PropertyPathHelper.CreateSelector <Product, object>("ImageUrl");

            return((value as IEnumerable).Cast <Product>().Select(selector).Distinct());
        }