You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It shouldn't be a much related to avalonia, nor a big problem. But users expect some build in solution for this integration.
We should at least have ready to show sample in this repo, which would answer these questions.
Some sample code to set up view locator using Microsoft DI:
publicclassViewLocator:IDataTemplate{privatereadonlyDictionary<Type,Func<Control>>_dic;publicViewLocator(IEnumerable<ViewLocationDescriptor>descriptors){_dic=descriptors.ToDictionary(x =>x.ViewModel, x =>x.Factory);}publicrecordViewLocationDescriptor(TypeViewModel,Func<Control>Factory);publicIControlBuild(objectparam)=>_dic[param.GetType()]();publicboolMatch(objectdata)=>_dic.ContainsKey(data.GetType());}publicstaticIServiceCollectionAddView<TViewModel,TView>(thisIServiceCollectionservices)whereTView:Control,new(){services.AddSingleton(newViewLocator.ViewLocationDescriptor(typeof(TViewModel),()=>newTView()));returnservices;}
Topics to cover
It shouldn't be a much related to avalonia, nor a big problem. But users expect some build in solution for this integration.
We should at least have ready to show sample in this repo, which would answer these questions.
Ideas for a sample
How to:
Additional context
Related:
AvaloniaUI/Avalonia#8588
AvaloniaUI/Avalonia#5241 (comment)
AvaloniaUI/Avalonia#8936
The text was updated successfully, but these errors were encountered: