string strXaml = @" <DataTemplate xmlns='HTTP://schemas.microsoft.com/client/2007'>
<Grid HorizontalAlignment='Center' VerticalAlignment='Center'>
<Grid.RowDefinitions>
<RowDefinition Height='35'></RowDefinition>
<RowDefinition Height='35'></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width='150'></ColumnDefinition>
<ColumnDefinition Width='150'></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Text='Col1'></TextBlock>
<TextBlock Text='Col2' Grid.Column='1'></TextBlock>
{0}
</Grid>
</DataTemplate>";

 

StringBuilder sb = new StringBuilder();
int k = 0;
foreach (var item in this.objTableCaseTemplate.lstDBCaseItemTemplate)
{
if (k >= 2) break;
string tbn = "DB_" + item.PhyTbName;
string s = item.ItemName;
sb.AppendLine("<TextBox Text='{Binding Path=" + tbn + "." + s + ",Mode=TwoWay }' Grid.Column='" + k + "' Grid.Row='1'/>");
k++;
}
strXaml = string.Format(strXaml, sb.ToString());
DataTemplate dtTemplate = (DataTemplate)XamlReader.Load(strXaml);
DataGridTemplateColumn tmpCol = new DataGridTemplateColumn();
tmpCol.Header = "某個組";
tmpCol.CellTemplate = dtTemplate;
this.dataGridCaseList.Columns.Add(tmpCol);
創作者介紹
創作者 shadow 的頭像
shadow

資訊園

shadow 發表在 痞客邦 留言(0) 人氣()