在listview中获取数据 [英] Get data in listview

查看:73
本文介绍了在listview中获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是C#.NET的新手。



我想要的是什么:



我想要当用户点击RIGHT DIV中的视频名称时,在LEFT DIV上获取视频。



我正在使用ListView和OnSelectedIndexChanged方法。



视频和视频名称在​​同一个表中。



我搜索了各种方法和技巧来获得这个,但没有得到我想要的Stack Overflow上的最后一个帖子。



我希望你们能帮我解决这个问题。



我唯一想要的就是点击视频并将其显示在div标签中。



我尝试了什么:



我搜索了很多,也在其他论坛上问了这个问题,但没有正确的解决方案,所以你们是我最后的希望。



如果可以使用任何其他方法而不是listview,建议被接受。



提前感谢。

解决方案

问题是在ListView中获取视频还是仅仅是数据本身?



以下是我在MVVMC-App中使用ListView的示例(ViewModel包含数据,我将它绑定到ListView)



注意,它只是一个如何将内容导入ListView的示例



< ListView ItemsSource ={Binding Persons}SelectedItem ={Binding SelectedPerson}x:Name =listViewPersons> 
< ListBox.ItemTemplate>
< DataTemplate>
< StackPanel Margin =0,0,0,0>
< StackPanel Orientation =Horizo​​ntal>
< TextBlock FontWeight =UltraBoldText ={Binding Name}/>
< TextBlock FontWeight =UltraBoldText = - />
< TextBlock FontWeight =UltraBoldText ={Binding PersNr}/>
< / StackPanel>
< StackPanel Orientation =Horizo​​ntal>
< TextBlock FontWeight =UltraBoldText =Erstellt am:/>
< TextBlock Text ={Binding CreationDate}/>
< / StackPanel>
< / StackPanel>
< / DataTemplate>
< /ListBox.ItemTemplate>
< / ListView>


I am new to C#.NET.

What I want:

I want to get VIDEO on LEFT DIV when user click on VIDEO NAME in RIGHT DIV.

I am using ListView and OnSelectedIndexChanged method.

Video and Video Name are in same TABLE.

I searched for various methods and trick to get this, but didn't get what I want so at-last posting in Stack Overflow.

I hope you guys help me to go through this.

The only thing I want is to get the video on click and show it in a div tag.

What I have tried:

I Searched for it alot and also asked this in other forums but didn't proper solution so you guys are my last hope for this.

Suggestions are accepted if any other method can be used rather than listview.

Thank's in advance.

解决方案

Is the problem to get the Video in the ListView or just the data itself?

Here is an Example how i did a ListView in an MVVMC-App (ViewModel contains the Data and i am binding it to the ListView)

Note, its just an example how to get content into a ListView

<ListView  ItemsSource="{Binding Persons}" SelectedItem="{Binding SelectedPerson}" x:Name="listViewPersons">
	<ListBox.ItemTemplate>
		<DataTemplate>
			<StackPanel Margin="0, 0, 0, 0">
				<StackPanel Orientation="Horizontal">
					<TextBlock FontWeight="UltraBold" Text="{Binding Name}"/>
					<TextBlock FontWeight="UltraBold" Text=" - "/>
					<TextBlock FontWeight="UltraBold" Text="{Binding PersNr}" />
				</StackPanel>
				<StackPanel Orientation="Horizontal">
					<TextBlock FontWeight="UltraBold" Text="Erstellt am:  " />
					<TextBlock Text="{Binding CreationDate}" />
				</StackPanel>
			</StackPanel>
		</DataTemplate>
	</ListBox.ItemTemplate>
</ListView>


这篇关于在listview中获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆