/// <summary>
        /// Generates the GridView columns.
        /// </summary>
        private void GenerateGridViewColumns(IDotvvmRequestContext context)
        {
            var grid = FindGridView();

            var itemDataContextStack = grid.GetItemDataContextStack(ItemsControl.DataSourceProperty);
            var dynamicDataContext   = new DynamicDataContext(itemDataContextStack, context)
            {
                ViewName = ViewName
            };

            // generate columns
            var entityPropertyListProvider = context.Configuration.ServiceProvider.GetService <IEntityPropertyListProvider>();
            var viewContext      = dynamicDataContext.CreateViewContext(context);
            var entityProperties = entityPropertyListProvider.GetProperties(itemDataContextStack.DataContextType, viewContext);

            // create columns
            var newColumns = new List <GridViewColumn>();

            foreach (var property in entityProperties)
            {
                // get the column provider
                var columnProvider = FindGridColumnProvider(dynamicDataContext, property);
                if (columnProvider == null)
                {
                    continue;
                }

                // create the column
                var column = columnProvider.CreateColumn(grid, property, dynamicDataContext);
                SetColumnCommonProperties(grid, property, column, dynamicDataContext);

                // add the column to the GridView
                newColumns.Add(column);
            }
            AddColumns(grid, newColumns);
        }
        protected virtual void BuildForm(DynamicDataContext dynamicDataContext)
        {
            var builder = dynamicDataContext.DynamicDataConfiguration.GetFormBuilder(FormBuilderName);

            builder.BuildForm(this, dynamicDataContext);
        }
 /// <summary>
 /// Finds the grid column provider.
 /// </summary>
 protected virtual IGridColumnProvider FindGridColumnProvider(DynamicDataContext dynamicDataContext, PropertyDisplayMetadata property)
 {
     return(dynamicDataContext.DynamicDataConfiguration.GridColumnProviders.FirstOrDefault(p => p.CanHandleProperty(property.PropertyInfo, dynamicDataContext)));
 }
 /// <summary>
 /// Sets the common properties of the grid view column.
 /// </summary>
 protected virtual void SetColumnCommonProperties(GridView grid, PropertyDisplayMetadata property, GridViewColumn column, DynamicDataContext dynamicDataContext)
 {
     column.HeaderText = property.DisplayName;
 }