ServerLigt动态生成列问题,请高人指教。
这个摸板杂样动态呢?
<ig:TemplateColumn Key="[Clm1]"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
IsSortable="False" >
<ig:TemplateColumn.ItemTemplate>
<DataTemplate>
<StackPanel Width="150" Orientation="Vertical">
<hx:HxLabel Name="lableDate"
Background="{Binding Path=[Clm1].BackColor, Mode=TwoWay}"
Content="{Binding Path=[Clm1].Text}"
Foreground="{Binding Path=[Clm1].ForceColor}" />
</StackPanel>
</DataTemplate>
</ig:TemplateColumn.ItemTemplate>
</ig:TemplateColumn>
我这样做的,结果显示不出来?请高人指教。
for (int i = 0; i < colms; i++)
{
TemplateColumn tempColumn = new TemplateColumn();
tempColumn.Key = "[Clm" + i + "]";
tempColumn.IsSorted = SortDirection.None;
StringBuilder CellTemp = new StringBuilder();
CellTemp.Append("<DataTemplate xmlns=\"http://schemas.microsoft.com/client/2007\">");
CellTemp.Append(" <StackPanel Width=\"150\" Orientation=\"Vertical\" xmlns=\"http://schemas.microsoft.com/client/2007\">");
CellTemp.Append("<hx:HxLabel xmlns:hx=\"clr-namespace:xxx.Controls;assembly=xxx.Controls\"");
CellTemp.Append(" Background=\"Red\"");
CellTemp.Append(" Content=\"Test\"");
CellTemp.Append(" Foreground=\"Blue\" ");
CellTemp.Append("/>");
CellTemp.Append("</StackPanel></DataTemplate>");
tempColumn.AddNewRowItemTemplate = (DataTemplate)XamlReader.Load(CellTemp.ToString());
grid.Columns.Add(tempColumn);
}
------解决方案--------------------
http://www.cnblogs.com/luosm/articles/2261826.html
这个不行吗?试试这个