I'm having a Collection of type Mobile
public class Mobile
{
public string MobileName { get; set; }
public string MobileOS { get; set; }
}
ObservableCollection<Mobile> MobileList = new ObservableCollection<Mobile>()
{
new Mobile() { MobileName = "iPhone 6", MobileOS = "IOS" },
new Mobile() { MobileName = "Galaxy S6", MobileOS = "Android" },
new Mobile() { MobileName = "Lumina", MobileOS = "Windows" },
}
The appropriate WPF DataGrid
(XAML)
<DataGrid Name="Grid1" AutoGenerateColumns="False" ItemsSource="{Binding MobileList, UpdateSourceTrigger=PropertyChanged}">
<DataGrid.Columns>
<!--Column 1-->
<DataGridTextColumn Binding="" Header="Index" />
<!--Column 2-->
<DataGridTextColumn Binding="{Binding MobileName}" Header="Name" />
<!--Column 3-->
<DataGridTextColumn Binding="{Binding MobileOS}" Header="OS" />
</DataGrid.Columns>
</DataGrid>
I need to set the Index value in Column 1. Kindly assist me how to set the index value for the column which is associated with the collection.
Note: I need this in XAML Level not in C# Code Level Implementation
Required Data Grid : Model Snapshot