Thanks in advance for the thoughts. Currently I have a RadGrid with a fair amount of comboboxes. In order to ensure that the comboboxes have been populated prior to drawing the grid, I have opted to create the columns programmatically after a chain of DDS HasLoaded events. When they iterate to 9, I call a programmatic build of the Grid. For lack of a better phrase, is there a better approach to incorporate a more robust XAML / MVVM approach? Thanks for the insight.
private void CheckIfCompleted()
{
callCount++;
Debug.WriteLine(callCount);
if (callCount == 9)
OnAsyncDone(new EventArgs());
}
protected virtual void OnAsyncDone(EventArgs e)
{
if (AsyncDone != null)
{
AsyncDone(this, e);
}
buildChildGrid();
}
private void buildChildGrid()
{
var cboColumn = new GridViewComboBoxColumn();
var cboColumn1 = new GridViewComboBoxColumn();
var cboColumn2 = new GridViewComboBoxColumn();
var cboColumn3 = new GridViewComboBoxColumn();
var txtColumn = new GridViewDataColumn();
var txtColumn2 = new GridViewDataColumn();
var txtColumn3 = new GridViewDataColumn();
var txtColumn4 = new GridViewDataColumn();
var chkColumn1 = new GridViewCheckBoxColumn();
{
txtColumn.UniqueName = "unitQtyColumn";
txtColumn.DataMemberBinding = new Binding("unitQty");
txtColumn.DataMemberBinding.Mode = BindingMode.TwoWay;
txtColumn.Header = "Quantity";
txtColumn.SortMemberPath = "unitQty";
txtColumn.Width = new GridViewLength(100, GridViewLengthUnitType.Pixel);
txtColumn.TextAlignment = TextAlignment.Center;
}
{
cboColumn.ItemsSource = qryOriginVarietalDomainDataSource.Data;
cboColumn.DisplayMemberPath = "oriVar";
cboColumn.SelectedValueMemberPath = "varietalID";
cboColumn.UniqueName = "cboVarietalIDColumn";
cboColumn.Header = "Origin - Varietal";
cboColumn.DataMemberBinding = new Binding("varietalID");
cboColumn.DataMemberBinding.Mode = BindingMode.TwoWay;
cboColumn.SortMemberPath = "varietalID";
cboColumn.Width = new GridViewLength(1, GridViewLengthUnitType.SizeToCells);
}
{
cboColumn1.ItemsSource = tblGradeDomainDataSource.Data;
cboColumn1.DisplayMemberPath = "gradeName";
cboColumn1.SelectedValueMemberPath = "gradeID";
cboColumn1.UniqueName = "gradeIDColumn";
cboColumn1.Header = "Grade";
cboColumn1.DataMemberBinding = new Binding("gradeID");
cboColumn1.DataMemberBinding.Mode = BindingMode.TwoWay;
cboColumn1.SortMemberPath = "gradeID";
cboColumn1.Width = new GridViewLength(1, GridViewLengthUnitType.SizeToCells);
}
{
txtColumn2.UniqueName = "unitPriceColumn";
txtColumn2.DataMemberBinding = new Binding("unitPrice");
txtColumn2.DataMemberBinding.Converter = new StringFormatValueConverter("{0:$##0.0000}");
//txtColumn2.DataMemberBinding.Converter = new StringFormatValueConverter("{0:C}");
txtColumn2.DataMemberBinding.Mode = BindingMode.TwoWay;
txtColumn2.Header = "Unit Price";
txtColumn2.SortMemberPath = "unitPrice";
txtColumn2.Width = new GridViewLength(125, GridViewLengthUnitType.Pixel);
txtColumn2.TextAlignment = TextAlignment.Center;
}
{
txtColumn3.UniqueName = "transDescColumn";
txtColumn3.DataMemberBinding = new Binding("transDesc");
txtColumn3.DataMemberBinding.Mode = BindingMode.TwoWay;
txtColumn3.Header = "Chop - Mark";
txtColumn3.SortMemberPath = "transDesc";
txtColumn3.Width = new GridViewLength(1, GridViewLengthUnitType.Star);
txtColumn3.MinWidth = 100;
}
{
cboColumn2.ItemsSource = tblLocationDomainDataSource.Data;
cboColumn2.DisplayMemberPath = "location";
cboColumn2.SelectedValueMemberPath = "locationID";
cboColumn2.UniqueName = "cboLocationColumn";
cboColumn2.Header = "Point of Purchase";
cboColumn2.DataMemberBinding = new Binding("poLocID");
cboColumn2.DataMemberBinding.Mode = BindingMode.TwoWay;
cboColumn2.SortMemberPath = "poLocID";
cboColumn2.Width = new GridViewLength(1, GridViewLengthUnitType.SizeToCells);
}
{
chkColumn1.UniqueName = "chkCertColumn";
chkColumn1.Header = "Cert";
chkColumn1.DataMemberBinding = new Binding("isCert");
chkColumn1.DataMemberBinding.Mode = BindingMode.TwoWay;
chkColumn1.SortMemberPath = "isCert";
chkColumn1.Width = new GridViewLength(30, GridViewLengthUnitType.Pixel);
chkColumn1.TextAlignment = TextAlignment.Center;
}
{
List<
string
> dropDownLoad_ArabicaRobusta = new List<
string
>();
dropDownLoad_ArabicaRobusta.Add("Arabica");
dropDownLoad_ArabicaRobusta.Add("Robusta");
cboColumn3.ItemsSource = dropDownLoad_ArabicaRobusta;
cboColumn3.UniqueName = "cboArabicaRobustaColumn";
cboColumn3.Header = "Species";
cboColumn3.DataMemberBinding = new Binding("robArab");
cboColumn3.DataMemberBinding.Mode = BindingMode.TwoWay;
cboColumn3.SortMemberPath = "robArab";
cboColumn3.Width = new GridViewLength(1, GridViewLengthUnitType.SizeToCells);
}
{
dg_tblPOLines.Columns.Add(txtColumn);
dg_tblPOLines.Columns.Add(cboColumn);
dg_tblPOLines.Columns.Add(cboColumn3);
dg_tblPOLines.Columns.Add(cboColumn1);
dg_tblPOLines.Columns.Add(chkColumn1);
dg_tblPOLines.Columns.Add(txtColumn2);
dg_tblPOLines.Columns.Add(txtColumn3);
dg_tblPOLines.Columns.Add(cboColumn2);
}