更新时间:2022-10-21 13:13:37
您只是没有填充列表视图
示例操作方法:
someName.ItemsSource = Data.PNumber();
您可以放入someName.ItemSource =//这样的特殊方法,如GetYourPNumbers()
在您的listview定义中添加someName
ItemContainerStyle ="{StaticResource ItemContStyle}";
ItemsSource ="{Binding}";
参考:
< a href ="http://***.com/questions/1927139/wpf-listview-databinding-to-generic-list-dynamically-filled-by-wcf-service"> http://***.com/Questions/1927139/wpf-listview-databinding-to-generic-list-dynamicly-filled by-wcf-service</a> [< a href ="http://***.com/questions/1927139/wpf- listview数据绑定到由wcf服务动态填充的通用列表" target ="_ blank" title ="New Window"> ^</a>]
>
Hi,
I''m trying to populate the List<string>
in ListView, but facing problem not at all able to populate the data.
Below giving the steps that I''m following please help.
class Data
{
//using cLR properties and not a dependency property (not sure whether that causing
//any problem)
private List<string> _pName;
private List<string> _pNumber;
public' List'<string>' PName
{
get { return _pName; }
set { _pName= value; }
}
public' List<string> PNumber
{
get { return _pNumber; }
set { _pNumber= value; }
}
//Getting data in PName and PNumber accordingly by some function call
My XAML looks like this -
'<listview selectedvaluepath="Value" name="someName" selectionmode="Single" margin="263,35,12,50">
'selectionchanged="some_SelectionChanged" focusable="False" fontweight="Bold" tabindex="4">
'<listview.view>
'<gridview>
'<gridview.columns>
'<gridviewcolumn header="Person Number" width="Auto" />
'<gridviewcolumn header="Person Name" width="Auto" />
' </gridview.columns>
'</gridview>
'</listview.view>
' </listview>
Search on this a lot but seems its not working.
Please let me know if you need any more details.
Thanks !!
You just didn''t populate your listview
Example how to do it:
someName.ItemsSource = Data.PNumber();
You can put into the someName.ItemSource=// a special method like GetYourPNumbers()
Add to your definition of the listview someName
ItemContainerStyle="{StaticResource ItemContStyle}";
ItemsSource="{Binding}";
refer:
<a href="http://***.com/questions/1927139/wpf-listview-databinding-to-generic-list-dynamically-filled-by-wcf-service">http://***.com/questions/1927139/wpf-listview-databinding-to-generic-list-dynamically-filled-by-wcf-service</a>[<a href="http://***.com/questions/1927139/wpf-listview-databinding-to-generic-list-dynamically-filled-by-wcf-service" target="_blank" title="New Window">^</a>]