I am trying to link a list of objects in a cs to an XAML file It shows me all the fields of the object even though I wrote that I only want the license number cs:
IBL bl = BLFactory.GetBL("1");
private ObservableCollection<BO.Bus> BusList = new ObservableCollection<BO.Bus>();//Bus List
public BusWindow()
{
InitializeComponent();
BusList=Convert<BO.Bus>(bl.GetAllBus());
lvBuses.ItemsSource = BusList;
}
public ObservableCollection<T> Convert<T>(IEnumerable<T> original)
{
return new ObservableCollection<T>(original);
}
xaml:
<Grid>
<ListView x:Name="lvBuses" ItemsSource="{Binding AllItems}" DisplayMemberPath="LicensePlate" HorizontalAlignment="Left" Height="271" Margin="271,32,0,0" VerticalAlignment="Top" Width="452">
<ListView.View>
<GridView >
<GridViewColumn Header="License number" Width="120"/>
<GridViewColumn>
<GridViewColumn.CellTemplate>
<DataTemplate>
<Button Click="ViewDetailsClick" Content="View Details" Margin="150,1,0,0" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
</Grid>