/// <summary> /// Performs the data-binding and builds the controls inside the <see cref="Repeater"/>. /// </summary> private void DataBind(RedwoodRequestContext context) { Children.Clear(); var dataSourceBinding = GetDataSourceBinding(); var dataSourcePath = dataSourceBinding.GetViewModelPathExpression(this, DataSourceProperty); var index = 0; var dataSource = DataSource; if (dataSource != null) { foreach (var item in GetIEnumerableFromDataSource(dataSource)) { var placeholder = new DataItemContainer { DataItemIndex = index }; placeholder.SetBinding(DataContextProperty, new ValueBindingExpression(dataSourcePath + "[" + index + "]")); Children.Add(placeholder); ItemTemplate.BuildContent(context, placeholder); index++; } } }
private void DataBind(RedwoodRequestContext context) { Children.Clear(); var dataSourceBinding = GetDataSourceBinding(); dataSourcePath = dataSourceBinding.GetViewModelPathExpression(this, DataSourceProperty); var dataSource = DataSource; string sortCommandPath = ""; if (dataSource is IGridViewDataSet) { sortCommandPath = dataSourcePath + ".SetSortExpression"; } else { var sortCommandBinding = GetCommandBinding(SortChangedProperty); if (sortCommandBinding != null) { sortCommandPath = sortCommandBinding.Expression; } } var index = 0; if (dataSource != null) { // create header row CreateHeaderRow(context, sortCommandPath); foreach (var item in GetIEnumerableFromDataSource(dataSource)) { // create row var placeholder = new DataItemContainer { DataItemIndex = index }; placeholder.SetBinding(DataContextProperty, new ValueBindingExpression(dataSourcePath + "[" + index + "]")); Children.Add(placeholder); CreateRow(context, placeholder); index++; } } }