Bonjour à tous,
je n'arrive pas à expliquer mon problème donc je viens vous en faire part

Mes classes modeles Dto sont encapsulées dans une classe Business Poco via les repositories

je construis un formulaire contenant un Combobox qui a besoin d'une liste de catégorie en ItemSource, et d'une catégorie par défaut en SelectedItem.
l'affectation de la liste de catégories à la propriété ItemSource fonctionne et j'ai bien mes Catégories visibles dans mon control. Le selectedItem quant à lui ne fonctionne pas, la catégorie affectée à ItemSource n'est pas prise en compte, et avec les outils de debuggage je m'aperçois que le SelectedItem est bien remplacé mais aucune classe "Catégorie" n'est affectée alors que je la voit dans le DataContext

J'ai testé sans l'encapsulation avec la classe buisness en appelant directement la classe Dto dans mon viewModel et la tout fonctionne sans modifier le code de binding et d'affichage.
Je pense donc que mon encapsulation n'est pas codée correctement.
je vous met les classes ci dessous :

RepositoriesUoW
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
    public class RepositoriesUoW : IRepositoriesUoW
    {
        private MiningContext ctx;
 
        public RepositoriesUoW()
        {
            CreateDbContext();
        }
 
        public RepositoriesUoW(MiningContext context)
        {
            ctx = context;
        }
 
        private void CreateDbContext()
        {
            ctx = new MiningContext();
        }
 
        private ICommunRepository<CategorieDto, CategoriePoco> _CategoriesPoco;
        private ICommunRepository<ModeleDto, ModelePoco> _ModelesPoco;
        private IRepository<FinderDto, FinderPoco> _FindersPoco;
        private IRepository<ExcavatorDto, ExcavatorPoco> _ExcavatorsPoco;
        private IRepository<RefinerDto, RefinerPoco> _RefinersPoco;
        private IRepository<FinderAmplifierDto, FinderAmplifierPoco> _FinderAmplifiersPoco;
        private IRepository<SearchModeDto, SearchModePoco> _SearchModesPoco;
        private IRepository<SetupDto, SetupPoco> _SetupsPoco;
        private IRepository<PlanetDto, PlanetPoco> _PlanetsPoco;
        private IRepository<EnhancerDto, EnhancerPoco> _EnhancersPoco;
        private IRepository<MaterialDto, MaterialPoco> _MaterialsPoco;
        private IRepository<ToolAccessoireDto, ToolAccessoirePoco> _ToolAccessoiresPoco;
        private IRepository<PlanetMaterialDto, PlanetMaterialPoco> _PlanetMaterialsPoco;
 
        public ICommunRepository<CategorieDto, CategoriePoco> CategoriesPoco
            => _CategoriesPoco == null? _CategoriesPoco = new CommunRepository<CategorieDto, CategoriePoco>(ctx) : _CategoriesPoco;
 
        public ICommunRepository<ModeleDto, ModelePoco> ModelesPoco
            => _ModelesPoco == null ? _ModelesPoco = new CommunRepository<ModeleDto, ModelePoco>(ctx) : _ModelesPoco;
 
        public IRepository<FinderDto, FinderPoco> FindersPoco
            => _FindersPoco == null ? _FindersPoco = new Repository<FinderDto, FinderPoco>(ctx) : _FindersPoco;
 
        public IRepository<ExcavatorDto, ExcavatorPoco> ExcavatorsPoco
            => _ExcavatorsPoco == null ? _ExcavatorsPoco = new Repository<ExcavatorDto, ExcavatorPoco>(ctx) : _ExcavatorsPoco;
 
        public IRepository<RefinerDto, RefinerPoco> RefinersPoco
            => _RefinersPoco == null ? _RefinersPoco = new Repository<RefinerDto, RefinerPoco>(ctx) : _RefinersPoco;
 
        public IRepository<FinderAmplifierDto, FinderAmplifierPoco> FinderAmplifiersPoco
            => _FinderAmplifiersPoco == null ? _FinderAmplifiersPoco = new Repository<FinderAmplifierDto, FinderAmplifierPoco>(ctx) : _FinderAmplifiersPoco;
 
        public IRepository<SearchModeDto, SearchModePoco> SearchModesPoco
            => _SearchModesPoco == null ? _SearchModesPoco = new Repository<SearchModeDto, SearchModePoco>(ctx) : _SearchModesPoco;
 
        public IRepository<SetupDto, SetupPoco> SetupsPoco
            => _SetupsPoco == null ? _SetupsPoco = new Repository<SetupDto, SetupPoco>(ctx) : _SetupsPoco;
 
        public IRepository<PlanetDto, PlanetPoco> PlanetsPoco
            => _PlanetsPoco == null ? _PlanetsPoco = new Repository<PlanetDto, PlanetPoco>(ctx) : _PlanetsPoco;
 
        public IRepository<EnhancerDto, EnhancerPoco> EnhancersPoco
            => _EnhancersPoco == null? _EnhancersPoco = new Repository<EnhancerDto, EnhancerPoco>(ctx) : _EnhancersPoco;
 
        public IRepository<MaterialDto, MaterialPoco> MaterialsPoco
            => _MaterialsPoco == null? _MaterialsPoco = new Repository<MaterialDto, MaterialPoco>(ctx) : _MaterialsPoco;
 
        public IRepository<ToolAccessoireDto, ToolAccessoirePoco> ToolAccessoiresPoco
            => _ToolAccessoiresPoco == null ? _ToolAccessoiresPoco = new Repository<ToolAccessoireDto, ToolAccessoirePoco>(ctx) : _ToolAccessoiresPoco;
 
        public IRepository<PlanetMaterialDto, PlanetMaterialPoco> PlanetMaterialsPoco
            => _PlanetMaterialsPoco == null ? _PlanetMaterialsPoco = new Repository<PlanetMaterialDto, PlanetMaterialPoco>(ctx) : _PlanetMaterialsPoco;
 
        public void Commit()
        {
            ctx.SaveChanges();
        }
    }
Repository
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
public class Repository<TDto, TPoco> : IRepository<TDto, TPoco>
        where TDto : class, new()
        where TPoco : IPoco<TDto>, new()
    {
        protected MiningContext Context { get; set; }
 
        protected DbSet<TDto> DbSet { get; set; }
 
        public Repository(MiningContext ctx)
        {
            Context = ctx ?? throw new ArgumentNullException("Null DbContext");
            DbSet = Context.Set<TDto>();
        }
 
        public TPoco Add(TPoco entity)
        {
            DbEntityEntry dbEntityEntry = Context.Entry(entity.GetDto());
            if (dbEntityEntry.State != EntityState.Detached)
            {
                dbEntityEntry.State = EntityState.Added;
            }
            else
            {
                DbSet.Add(entity.GetDto());
            }
            SaveChanges();
            return entity;
        }
 
        public void Delete(int id)
        {
            TPoco entity = GetById(id);
            if (entity == null) return; // not found; assume already deleted.
            Delete(entity);
        }
 
        public void Delete(TPoco entity)
        {
            DbEntityEntry dbEntityEntry = Context.Entry(entity.GetDto());
            if (dbEntityEntry.State != EntityState.Deleted)
            {
                dbEntityEntry.State = EntityState.Deleted;
            }
            else
            {
                DbSet.Attach(entity.GetDto());
                DbSet.Remove(entity.GetDto());
            }
            SaveChanges();
        }
 
        public IQueryable<TPoco> GetAll()
        {
            return DbSet.ToPocoIQueryable<TDto, TPoco>();
        }
 
        public TPoco GetById(int id)
        {
            return DbSet.Find(id).ToPoco<TDto, TPoco>();
        }
 
        public void Update(TPoco entity)
        {
            DbEntityEntry dbEntityEntry = Context.Entry(entity.GetDto());
            if (dbEntityEntry.State == EntityState.Detached)
            {
                DbSet.Attach(entity.GetDto());
            }
            dbEntityEntry.State = EntityState.Deleted;
            SaveChanges();
        }
 
        public void SaveChanges()
        {
            Context.SaveChanges();
        }
    }
CommunRepository
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
    public class CommunRepository<TDto, TPoco> : Repository<TDto, TPoco>, ICommunRepository<TDto, TPoco>
        where TDto : CommunDto, new()
        where TPoco : class, IPoco<TDto>, new()
    {
        public CommunRepository(MiningContext ctx)
            : base(ctx)
        {
 
        }
 
        public TPoco GetByNom(string nom)
        {
            return DbSet.FirstOrDefault(x => x.Nom == nom).ToPoco<TDto, TPoco>();
        }
    }
Et enfin les classes statiques d'extensions qui sont à mon avis la source du problème
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
28
29
30
31
32
33
34
public static class CollectionExtensions
    {
        public static Collection<TPoco> ToPocoCollection<TDto, TPoco>(this ICollection<TDto> dtos)
            where TPoco : IPoco<TDto>, new()
            where TDto : class
        {
            Collection<TPoco> pocos = new Collection<TPoco>();
            TPoco poco;
            foreach (var dto in dtos)
            {
                poco = new TPoco();
                poco.SetDto(dto);
                pocos.Add(poco);
            }
            return pocos;
 
        }
 
        public static IQueryable<TPoco> ToPocoIQueryable<TDto, TPoco>(this DbSet<TDto> dtos)
            where TPoco : IPoco<TDto>, new()
            where TDto : class
        {
            Collection<TPoco> pocos = new Collection<TPoco>();
            TPoco poco;
            foreach (var dto in dtos)
            {
                poco = new TPoco();
                poco.SetDto(dto);
                pocos.Add(poco);
            }
            return pocos.AsQueryable();
 
        }
    }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
    public static class DtoExtensions
    {
        public static TPoco ToPoco<TDto, TPoco>(this TDto dto)
            where TPoco : IPoco<TDto>, new()
            where TDto : class
        {
            TPoco poco = new TPoco();
            poco.SetDto(dto);
            return poco;
        }
    }
et voila enfin la source du binding que j'ai simplifié pour test mais qui ne fonctionne pas plus
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
 
            CategoriesPoco = repos.CategoriesPoco.GetAll().ToList();
            SelectedCategorie = repos.CategoriesPoco.GetByNom("Tool");
Le binding est fait en XAML, et ne fonctionne pas non plus en passant par le code-behind

Merci d'avance pour votre aide