I have datagrid, which should allow user add row. But it should add item where one of the field defined by the one of the model properties. Have anybody an idea how to do it. Code like this:
public class OrderWindowModel : BaseModel
{
public ObservableCollection<GoodM> Goods { get; set; }
public Service Service { get; set; }
}
public class GoodM : BaseModel
{
public Service Service { get; set; }
public List<Good> Goods
{
get{ return Service.GoodsL; }
}
public Good CurrGood { get; set; }
}
And xaml
<custom:DataGrid Margin="5" Grid.Row ="1" CanUserAddRows="True" CanUserDeleteRows="True"
AutoGenerateColumns="False" SnapsToDevicePixels="True" SelectedIndex="0"
CanUserReorderColumns="True" ItemsSource="{Binding Goods}" Grid.ColumnSpan="2">
<custom:DataGrid.Columns>
<custom:DataGridComboBoxColumn Header="Товар" DisplayMemberPath="{Binding Name}"
SelectedItemBinding="{Binding CurrGood}" ItemsSource="{Binding Goods}" Width="*">
</custom:DataGridComboBoxColumn>
</custom:DataGrid.Columns>
</custom:DataGrid>