Shock
Dependency Injection returning null value
I've created a WPF application that uses DI for the View/Viewmodel. I'm attempting to create a CS file to deal with the program logic that uses a dependency injected Service Wrapper. However, whenever I call the Service in the new class, the value is returning as null. I've included a shortened version below that hopefully gets the point across.
MyService.CS MainWindow.xaml.cs MainWindow.Xaml MainViewModel.cs App.xaml App.Xaml.Cs There is a lot more there, but they are all instantiated as singleton. HomeView.xaml.Cs And finally. Logic.CS
MyService.CS MainWindow.xaml.cs MainWindow.Xaml MainViewModel.cs App.xaml App.Xaml.Cs There is a lot more there, but they are all instantiated as singleton. HomeView.xaml.Cs And finally. Logic.CS
21 replies
WPF local: when using Dependency Injection
Hello,
My WPF app is utilizing dependency injection following https://achraf-chennan.medium.com/net-core-dependency-injection-for-wpf-core-62dc282690f8 (which removes StartupUri from the App.xaml file).
When I'm attemping to utilize data binding, but local:SessionConverter isn't being recognize and I'm not understanding how to work around it as I'm unable to set the DataContext in the main window due to the parameters.
The .xaml code looks like the following (button data removed)
Could anyone point me in the right direction here?
14 replies
Out Parameter Question
I think this should be simple, but I am coming up blank on a method call with an out parameter. (The example below is basic but my actual code requires the parameters)
File1.Cs
If I am trying to call the Position Method in File2.Cs
What do I put for the last parameter on p.Position?
16 replies