我在程序中使用Hubsection,并且<HubSection>
有一个ListView。但我无法将数据绑定到ListView。我曾经尝试使用,{binding}
但是在输出中我变得空白,而在使用时x:bind
我得到的错误是
没有为DataTemplate定义DataType。包含x:Bind的模板需要使用'x:DataType'指定数据类型
帮助我解决这个问题。这是我的代码:
.xaml
<Hub Header="abc" FontWeight="Bold">
<HubSection Header="header1" x:Name="hub1">
<DataTemplate >
<ListView x:Name="list1" ItemsSource="{x:Bind info}">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<Image Source="{X:Bind image}"></Image>
<TextBlock Text="{x:Bind name}"/>
</StackPanel>
<TextBlock Text="{x:Bind bio}"/>
</StackPanel>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</DataTemplate>
</HubSection>
<HubSection Header="header 2">
<DataTemplate>
</DataTemplate>
</HubSection>
</Hub>
</Grid>
Run Code Online (Sandbox Code Playgroud)
.cs
namespace app1
{
public class info
{
public String name { get; set; }
public String bio { get; set; }
public String image …
Run Code Online (Sandbox Code Playgroud)