如何从UWP背后的代码中添加listView和方向为水平?
我必须从ADER背后的代码中实现此语法,该如何
<ListView>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<ItemsStackPanel Orientation="Horizontal"
/>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
</ListView>
从UWP背后的代码中实现属性元素语法?
I have to achieve this syntax from code behind how can I do that
<ListView>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<ItemsStackPanel Orientation="Horizontal"
/>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
</ListView>
in general how can I achieve property element syntax from code behind in uwp?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
评论(2)
深空失忆2025-01-28 05:14:31
如何从UWP背后的代码中添加ListView?
的水平。
对于在后面的代码中制作itemSpaneltemplate
,您可以分析itemspaneltemplate
字符串,然后将其传递到ListView的iteg> itemspanel
。
private void ApplyItemsStackPanelAsItemsPanel(ItemsControl itemsControl)
{
var itemsPanelTemplateXaml =
$@"<ItemsPanelTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>
<ItemsStackPanel Orientation='Horizontal'/>
</ItemsPanelTemplate>";
itemsControl.ItemsPanel = (ItemsPanelTemplate)XamlReader.Load(itemsPanelTemplateXaml);
}
用法
private void BuildListView()
{
var listview = new ListView();
ApplyItemsStackPanelAsItemsPanel(listview);
listview.ItemsSource = new string[] { "1", "2", "3", "4" };
this.Content = listview;
}
~没有更多了~
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
您可以这样实现。
You can achieve it this way.