ServerLigt动态生成列问题,请高人指教。

wylq21235 2012-07-17 10:41:21
这个摸板杂样动态呢?
<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:Controls;assembly=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);

}
...全文
371 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
白鸽 2012-07-17
  • 打赏
  • 举报
回复
http://www.cnblogs.com/luosm/articles/2261826.html
这个不行吗?试试这个

8,757

社区成员

发帖
与我相关
我的任务
社区描述
WPF/Silverlight相关讨论
社区管理员
  • WPF/Silverlight社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧