[uwp] [c#] [xaml]如何绑定包含列表< string>的对象到listview datatemplate? [英] [uwp][c#][xaml]how to bind an object containing list<string> to listview datatemplate ?

查看:102
本文介绍了[uwp] [c#] [xaml]如何绑定包含列表< string>的对象到listview datatemplate?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试绑定绑定包含List< string>的对象listview as observablecollection,但我得到的是下面的一些东西,我正在使用x:bind当前



但我试图实现类似下面的内容


解决方案

嗨!


鉴于itemssource,它只是一个列表< string>您不需要使用x:bind。 


以下是代码示例: 

< ; ListView ItemsSource =" {Binding TheNameOfObservableCollection}" 
>
< ListView.ItemTemplate>
< DataTemplate>

< TextBlock Text =" {Binding}"
Margin =" 20,0,0,0"
/>
< / DataTemplate>
< /ListView.ItemTemplate>

< / ListView>



希望它有用。


< p style ="border:none; font-family:'Segoe UI','Lucida Grande',Verdana,Arial,Helvetica,sans-serif; outline:0px; padding-right:0px; color:#333333; font-size :14px">
如果是对你有好处,你能否将这个答案标记为你的问题的答案?



在twitter上关注我:  https://twitter.com/NordineMhoumadi



i am trying to bind bind an object containing List<string> to listview as observablecollection but all i was getting is some thing like below, i am using x:bind currently

but i was trying to achieve something like below

解决方案

Hi!

Given that the itemssource it's just a list<string> you don't need to use x:bind. 

Here is the sample of code : 

            <ListView ItemsSource="{Binding TheNameOfObservableCollection}"
>
                <ListView.ItemTemplate>
                    <DataTemplate>
                        
                                <TextBlock Text="{Binding}"
                                           Margin="20,0,0,0"
                                            />
                    </DataTemplate>
                </ListView.ItemTemplate>

            </ListView>

Hope it wil be useful.

If it's good for you, can you mark this answer as answer of your question please?

Follow me on twitter : https://twitter.com/NordineMhoumadi


这篇关于[uwp] [c#] [xaml]如何绑定包含列表&lt; string&gt;的对象到listview datatemplate?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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