Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6565005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:02:21+00:00 2026-05-25T14:02:21+00:00

I have Views and ViewModels in separated projects. What is the best practice to

  • 0

I have Views and ViewModels in separated projects.

What is the best practice to getting from some viewmodel config datas, for example username, set of privelleges for users, which I set after launch of application in App.xaml.cs

In older project I had views and viewmodels in the same project, and I was getting this datas by:

App _app = Application.Current as App;
var userName=_app.UserName;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:02:21+00:00Added an answer on May 25, 2026 at 2:02 pm

    I’m not sure why you have your Views and VMs in seperate projects. We normally use a singleton pattern to store application wide settings e.g.

    public class ApplicationContext
    {
    
        #region Declarations
    
        // Static instance of the application class.
        private static ApplicationContext _instance;
    
        #endregion
    
        #region Constructor
    
        public ApplicationContext()
        {
            //SecurityContext is a custom class that stores data on the current user  
            this.SecurityContext = new SecurityContext();
        }
    
        // Static instance creator.
        public static ApplicationContext Instance()
        {
            if (_instance == null)
            {
                _instance = new ApplicationContext();
            }
            return _instance;
        }
    
        #endregion
    
        #region Properties
    
        public SecurityContext SecurityContext { get; set; }
    
        #endregion
     }
    

    ..and then to use it anywhere in the app:

    var currentUserName = ApplicationContext.Instance().SecurityContext.CurrentUser.User.FullName
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 5 views in my ASP.NET MVC application. Some data were captured from
Is it considered bad practice to have multiple views for same URL in MVC,
Getting my head around MVC today and ran across the best practice of not
I have come accross two ways of initializing Views and ViewModels in WPF CAL
I have a View with ViewModel as datacontext ( set in code) . In
In my WPF application I have a View that is given a ViewModel, and
I have a DatePicker working on a View which also has a ViewModel associated
I have senario in which one view and view has binding with multiple ViewModel.
I have two views, one view takes the whole screen, the second view covers
I have my views render to route requests like /controller/action (for instance, /Page/Create), so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.