I am using the hubsection in my program and in <HubSection>
there is a ListView. but I am not able to bind the data to ListView. I had tried using {binding}
but I am getting blank in output and when using the x:bind
I am getting error that is
No DataType defined for DataTemplate. Templates containing x:Bind need a DataType to be specified using 'x:DataType'
Help me in this problem. Here is my code:
.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>
.cs
namespace app1
{
public class info
{
public String name { get; set; }
public String bio { get; set; }
public String image { get; set; }
}
public sealed partial class abcde : Page
{
ObservableCollection<info> obsinfo = new ObservableCollection<info>();
public abcde()
{
this.InitializeComponent();
filldata();
}
void filldata()
{
obsinfo.Add(new info { name = "data1", image = "images/data1.png", bio = "" });
obsinfo.Add(new info { name = "data2", image = "images/data2.png", bio = "" });
}
}
}