Пример #1
0
        /// <summary>
        /// Stores a single resource
        /// </summary>
        /// <param name="resourceName"> The name of the resource </param>
        public void AddResource(string resourceName)
        {
            // Find the resource
            var resource = _resourceLocator.FindResource(resourceName);

            // If resource exists
            if (resource != null)
            {
                // Add resource to list
                _resources.Add(resourceName, resource);
            }
        }
Пример #2
0
        private void Columns_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.NewItems == null)
            {
                return;
            }
            DataGridColumn[] array = e.NewItems
                                     .OfType <DataGridColumn>()
                                     .Where(column => column.GetIsFilterVisible() && column.HeaderTemplate == null)
                                     .ToArray();

            if (array.Any())
            {
                IResourceLocator resourceLocator = this._dataGrid.GetResourceLocator();
                object           obj             = resourceLocator?.FindResource(DataGrid, DataGridFilter.ColumnHeaderTemplateKey)
                                                   ?? this._dataGrid.TryFindResource((object)DataGridFilter.ColumnHeaderTemplateKey);
                DataTemplate dataTemplate = (DataTemplate)obj;
                foreach (DataGridColumn dataGridColumn in array)
                {
                    dataGridColumn.HeaderTemplate = dataTemplate;
                }
            }
        }