Autor Beitrag
doubleII
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 52



BeitragVerfasst: Mi 13.06.18 08:44 
Hallo zusammen,

ich versuche seit zwei Tage folgendes:

Ich habe in der ViewModel zwei properties.
ausblenden 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

ausblenden 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 user profile iconTh69: Topic aus Sonstiges (.NET) verschoben am Mi 13.06.2018 um 10:04
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4764
Erhaltene Danke: 1052

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: Mi 13.06.18 10:02 
Das scheint mir mehr eine Frage für den DevExpress-Support zu sein, aber evtl. hilft ListBoxEdit EditValue conversion problem when SelectionMode is "Extended" (auch wenn du "Multiple" verwendest): teste mal die unten angehängte "sample.zip" und vergleiche den Code dann mit deinem.