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 7018561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:04:01+00:00 2026-05-27T23:04:01+00:00

WPF can be infuriating sometimes. I have a fairly simple application that consists of

  • 0

WPF can be infuriating sometimes.

I have a fairly simple application that consists of a single main window that contains a tab control and several tabs. I did not like the idea of having the code for all tabs in the same file, so I used the answer from this question to break out each tab into a separate user control.

Inside my main window I have an instance of an object that contains application settings, and some other application-wide data. Several of my tabs require access to this data for data binding purposes. I have not been able to find a good way to accomplish this.

First I tried to access the parent window in the controls Loaded event and get a reference to the property in the main window that exposed the settings object, as shown in the code below. This kind of works, except the Loaded event is fired every time the tab gains focus. Also, this event occurs late in the control life cycle so I am not able to bind to any of the properties in this object in the user controls XAML.

private void MyUserControl_Loaded(object sender, RoutedEventArgs e)
{
    this.ApplicationSettings = ((MainWindow)Window.GetWindow(this)).ApplicationSettings;
}

Then I experimented with passing the data into the user controls constructor, but there is no way to do that in XAML.

Given that these are application-wide settings I could make the ApplicationSettings class singleton and reference it everywhere, but I would prefer not to do that for unit testing purposes.

So how does one accomplish something like this? Is my approach just fundamentally flawed? In my mind all of these UI elements are part of the same window and therefore should be able to access data from the main window, but the object model does not appear to allow this.

  • 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-27T23:04:02+00:00Added an answer on May 27, 2026 at 11:04 pm

    You could put the settings object into a static property in a wrapper class (SettingsHolder in this example and reference it application wide via

    in XAML:

    {Binding SettingName, Source={x:Static local:SettingsHolder.Settings}}
    

    with local being the namespace your SettingsHolder class is in.

    in Code:

    var x = SettingsHolder.Settings.SettingName;
    SettingsHolder.Settings.SettingName = x;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to create a WPF application that can be deployed as either a XBAP
hopefully some WPF ninja can explain to me why if I have a tab
i have a VSTO application(WPF) which can save an opened Excel File on a
I have a solution that has three projects: WPF Application Class Library NUnit Testing
I am trying to create a basic WPF application that can store an encrypted
In WPF: Can someone please explain the relationship between DependencyProperty and Databinding? I have
Can both WPF and Windows forms controls be used within one application? How difficult
I'd like to make some custom MenuHeaders in WPF so I can have (for
I have a WPF application and a Silverlight application. They are both used to
Can WPF Browser application run on IPAD\IPHONE?

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.