У меня есть приложение WPF MVVM с двумя объектами. Один-один. У меня есть два репозиторию, которые предоставляют мне данные для каждого объекта из моей базы данных. Orm is ef core. < /P>
Вот мои две коллекции в MainViewModel. < /P>
MainViewModel
public ReadOnlyObservableCollection Sets { get; }
DTO
public class Set(int id, string name) : IdDto(id)
{
public string Name { get; set; } = name;
public List? Words { get; set; }
}
< /code>
MainViewModel
public ReadOnlyObservableCollection Words { get; }
DTO
public class Word(int id, string name, string? definition, string? imagePath, bool isFavorite, bool isLastWord, int setId) : IdDto(id)
{
public string Name { get; set; } = name;
public string? Definition { get; set; } = definition;
public string? ImagePath { get; set; } = imagePath;
public bool IsFavorite { get; set; } = isFavorite;
public bool IsLastWord { get; set; } = isLastWord;
public int SetId { get; set; } = setId;
public Set? Set { get; set; }
}
< /code>
I have a collection of sets. Everyone of them contains a collection of words. So, how can i bind them in the view?
//I was only be able to do something like this.
< /code>
I have a button in this view. My ultimate goal is to press this button and go to another view with the selected set and it's words (bound entity).
Something like
У меня есть приложение WPF MVVM с двумя объектами. Один-один. У меня есть два репозиторию, которые предоставляют мне данные для каждого объекта из моей базы данных. Orm is ef core. < /P> Вот мои две коллекции в MainViewModel. < /P> [code]MainViewModel public ReadOnlyObservableCollection Sets { get; }
DTO public class Set(int id, string name) : IdDto(id) { public string Name { get; set; } = name;
public List? Words { get; set; } } < /code> MainViewModel public ReadOnlyObservableCollection Words { get; }
DTO public class Word(int id, string name, string? definition, string? imagePath, bool isFavorite, bool isLastWord, int setId) : IdDto(id) { public string Name { get; set; } = name;
public string? Definition { get; set; } = definition;
public string? ImagePath { get; set; } = imagePath;
public bool IsFavorite { get; set; } = isFavorite;
public bool IsLastWord { get; set; } = isLastWord;
public int SetId { get; set; } = setId;
public Set? Set { get; set; } } < /code> I have a collection of sets. Everyone of them contains a collection of words. So, how can i bind them in the view?
//I was only be able to do something like this.
< /code> I have a button in this view. My ultimate goal is to press this button and go to another view with the selected set and it's words (bound entity). Something like [/code]