Hello,
I would like to have a column as a combobox, where I can make a choice and that selectedItem shall be then saved in a property in the ViewModel.
The underlying CashflowScenarioUnitModel has a Name (string) property, ScenarioID (int)
public List<CashflowScenarioUnitModel> ScenarioNames{ get { return CashflowScenarioUnitDropDowns;}}
public CashflowScenarioUnitModel Scenario{ get{ return _cashflowUnitScenarioModel; } set{ if (_cashflowUnitScenarioModel == value) { return; } RaisePropertyChanged(Scenario); }}
<igDP:Field Name="Scenario"> <igDP:Field.Settings> <igDP:FieldSettings EditorType="{x:Type igEditors:XamComboEditor}"> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamComboEditor}"> <Setter Property="ItemsSource" Value="{Binding DataItem.ScenarioNames}"/> <Setter Property="DisplayMemberPath" Value="Name"/> <Setter Property="ValuePath" Value="ScenarioID" /> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:Field.Settings></igDP:Field>
The problem is already in the xaml that I dont want to bind to the ScenarioID, but rather to the selectedItem within the bound collection and store that selection into the Scenario property. How would I do that?And another question is, some utilise a CollectionView and inject the List<ViewModel> in it. How is this advantageous?
Many Thanks for your help,Houman
Hi i'd also like to do this, can anyone suggest a method?
Here you go, took me a while to work this out
<DataPresenter:UnboundField DataType="{x:Type Model:RF_RingStatus}" BindingPath="RF_RingStatus" Label="Ring Status" Width="Auto" BindingMode="TwoWay"> <DataPresenter:UnboundField.Settings> <DataPresenter:FieldSettings EditorType="{x:Type Editors:XamComboEditor}" > <DataPresenter:FieldSettings.EditorStyle> <Style TargetType="{x:Type Editors:XamComboEditor}"> <Setter Property="ItemsSource" Value="{Binding Path=DataContext.RingStatus, Source={StaticResource spy}}" /> <Setter Property="DisplayMemberPath" Value="Name" /> </Style> </DataPresenter:FieldSettings.EditorStyle> </DataPresenter:FieldSettings> </DataPresenter:UnboundField.Settings> </DataPresenter:UnboundField>