在ListView中处理SwapchainPanel
我的XAML代码
<ListView x:Name="ListVideo"
ItemsSource="{x:Bind ScreenList}"
VerticalAlignment="Stretch"
FlowDirection="LeftToRight"
Grid.Row="1"
ScrollViewer.VerticalScrollBarVisibility="Hidden"
ScrollViewer.HorizontalScrollBarVisibility="Hidden">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<controls:UniformGrid></controls:UniformGrid>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
<Grid Background="White"
BorderBrush="White"
BorderThickness="1">
<SwapChainPanel x:Name="swapChain"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"/>
</Grid>
</DataTemplate>
</ListView.ItemTemplate></ListView>
带有screenlist
是observableCollection
的类型。因此,问题是如何在listView中添加新的swapchainpanel
。
我打算添加swapchainpanel
项目,并且在每个项目中,我都使用DirectX渲染视频,因此我想在代码范围内将Object SwapchainPanel
项目进行处理。
谢谢。
I have my xaml code
<ListView x:Name="ListVideo"
ItemsSource="{x:Bind ScreenList}"
VerticalAlignment="Stretch"
FlowDirection="LeftToRight"
Grid.Row="1"
ScrollViewer.VerticalScrollBarVisibility="Hidden"
ScrollViewer.HorizontalScrollBarVisibility="Hidden">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<controls:UniformGrid></controls:UniformGrid>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
<Grid Background="White"
BorderBrush="White"
BorderThickness="1">
<SwapChainPanel x:Name="swapChain"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"/>
</Grid>
</DataTemplate>
</ListView.ItemTemplate></ListView>
with ScreenList
is type of ObservableCollection
. So the question is how can I add new SwapChainPanel
in the ListView?.
I intend to add SwapChainPanel
item, and with each item I use DirectX to render video, so i want to get the object SwapChainPanel
item in code-behind to process then.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在ListView DataTemplate中放置的swapchainpanel的ListView中添加新的SwapchainPanel,而当前ListView
itemssource
is observableCollection。因此,您只需要将新项目添加到ObservableCollection中,ListView将自动渲染新项目。You could get itemContainer with
更新
作为Hoka Biu评论,您还可以在Swapchainpanel加载事件中获得Swapchain实例。
You have placed SwapChainPanel in the Listview DataTemplate, and current listview
ItemsSource
is ObservableCollection. So you just need add new item into ObservableCollection, the listview will render new item automatically.You could get itemContainer with ContainerFromItem method, and find swapChain with name in
ContentTemplateRoot
.Update
As the Hoka Biu comment below, you could also get swapChain instance within SwapChainPanel Loaded event.