Hallo zusammen,
ich versuche seit zwei Tage folgendes:
Ich habe in der ViewModel zwei properties.
C#-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27:
| public List<Project> Projects { get; set; } public List<Project> SelectedProjects { get => OnGetProperty<List<Project>>(); set => OnSetProperty(value); }
public ViewModel(IList<Project> projects) { Projects = projects.ToList<Project>(); SelectedProjects = new List<Project>(); }
protected override bool OnLoad() { Header = Resources.Strings.Common.Projects; OkCommand = new Command(OpenProject);
return true; }
private void OpenProject() { DialogResult = DialogResult.OK; Invoke(CloseAction); } |
Ich habe ein View und in der View habe ich eine ListBox
XML-Daten
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16:
| <dxe:ListBoxEdit ItemsSource="{Binding Path=Projects}" EditValue="{Binding SelectedProjects, Mode=TwoWay}" SelectionMode="Multiple" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="600" Height="400" ScrollViewer.VerticalScrollBarVisibility="Visible"> <dxe:ListBoxEdit.ItemTemplate> <DataTemplate DataType="models:Project"> <StackPanel Orientation="Horizontal"> <Label Content="{Binding Path=Name}" /> </StackPanel> </DataTemplate> </dxe:ListBoxEdit.ItemTemplate> </dxe:ListBoxEdit> |
Das Problem ist folgendes, wenn ich ein oder mehrere Projekte auswähle und auf die OK Taste drucke lande ich in der OnLoad Methode und dann in die OpenProject Methode. Alles wunderbar aber der Counter des SelectedProject ist '0'. Ich habe versucht, anstatt List ObsolationCollection zu verwenden, es ist immer das selbe, der Counter ist = 0. Kann mir jemand sagen was ich falsch mache.
Danke!
Gruß
doubleII
Moderiert von Th69: Topic aus Sonstiges (.NET) verschoben am Mi 13.06.2018 um 10:04