I have:
public class Extra
{
public string Name {get;set;}
}
and I have
public class CarViewModel
{
public ObservableCollection<Extra> OwningExtras { get; set; }
public static IEnumerable<Extra> AllExtras
{
get
{
return Extra.GetAllExtras();
}
}
public CarViewModel()
{
owningExtras=Extra.GetAvailableExtrasForCar(idCar)
}
}
and CarView looks like:
<Grid >
<ListBox ItemsSource="{Binding}" Name="lbExtras">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<CheckBox"/> //How implement adding and removing Extras
<TextBlock Text="{Binding Path=Name}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</UserControl>
And I wonder what connect to this.DataContext? And then how to notice that something is changed (Checked checkbox means that this car has this extra)