© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
1 reply
ancientfuture

❔ Best approach to share several properties application-wide in a WinUI3 project?

Hi, I am looking for the preferred way, following the best practices for a small scale desktop application, to share properties from various
ContentDialog
ContentDialog
s,
UserControl
UserControl
s and a
Window
Window
throughout the application such that the data is accessible from the other
ContentDialog
ContentDialog
s or
UserControl
UserControl
s.

The approach I have in my right now is to create a static
SessionState
SessionState
class to store all the properties in one place and use it to access the saved properties of the current Desktop session of the application using it.

Out of the blue, a related query is that can I use Dependency Injection here to achieve the same? If yes, any advice will be very helpful.

A
SessionState
SessionState
class is also required by us to be able to implement the
New
New
Open
Open
and
Save
Save
file functions in our application. So is it a good idea to use a static class for this purpose?

I am a beginner w.r.t project architecture and Dependency Injection (but if it's useful here, I will give it a go!) and this is my first time creating a desktop application, using C#. I have experience with web applications. So any advice in moderately laymen terms will be greatly appreciated. Thanks!
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Unable to profile WinUI3 application
C#CC# / help
3y ago
WinUI3 project will not launch when packaged with Windows Application Packaging Project
C#CC# / help
2y ago
Best approach to SetThreadExecutionState
C#CC# / help
3y ago
Creating Installer for WinUI3 project
C#CC# / help
3y ago