c#写itempaneltemplate探秘

参考自:http://stackoverflow.com/questions/8398000/how-to-set-itemspaneltemplate-to-a-dynamically-created-grid-in-code-behind

c#赋值itempaneltemplate修正:

stackoverflow中的Parse,换成load就可以了。
 private ItemsPanelTemplate GetItemsPanelTemplate()
        {
            string xaml = @"<ItemsPanelTemplate   xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>
                          <StackPanel Margin='50'></StackPanel>
                    </ItemsPanelTemplate>";
            return XamlReader.Load(xaml) as ItemsPanelTemplate;
        }

  

 

 

 

posted on 2014-06-13 11:22  鸣动我心  阅读(467)  评论(0编辑  收藏  举报