I have created a "Listview" and a "Gridview" to show some data, and everything looks fine, but whenever I add data to the "Listviews ItemsSource", it doesn't show it, the only thing I can see are marked lines (see below).
The XAML code for the build up is as follows:
<ListView Name="lstView">
<ListView.View>
<GridView AllowsColumnReorder="True" ColumnHeaderToolTip="Info">
<GridViewColumn DisplayMemberBinding="{Binding Path=Item}" Header="Item" Width="100"/>
<GridViewColumn DisplayMemberBinding="{Binding Path=Qty}" Width="100">
<GridViewColumnHeader>Qty
<GridViewColumnHeader.ContextMenu>
<ContextMenu
Name="Quantity">
<MenuItem Header="Ascending" />
<MenuItem Header="Descending" />
</ContextMenu>
</GridViewColumnHeader.ContextMenu>
</GridViewColumnHeader>
</GridViewColumn>
<GridViewColumn DisplayMemberBinding="{Binding Path=Price}"
Header="Price" Width="100"/>
</GridView>
</ListView.View>
</ListView>
CS part:(forgot to add this part, the class used to store the data)
Class used:
public class MaterialsPicked
{
public string Item;
public double Qty;
public double Price;
}
And the data inserted:
ObservableCollection<MaterialsPicked> materialsPicked = new ObservableCollection<MaterialsPicked>
{
new MaterialsPicked { Item = "Test", Qty = 1, Price = 200 },
new MaterialsPicked { Item = "Test2", Qty = 2, Price = 400 }
};
lstView.ItemsSource = materialsPicked;
And here is a picture of window, clearly it does add 2 lines to the listview, but the data itself is not showing up, and I am unsure what exactly I am missing.
@Clemens
Had the simple solution.
I was using fields instead of properties, changing it to public properties fixed the issue.