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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:08:11+00:00 2026-06-11T03:08:11+00:00

I deleted the CodeBehind of my MainWindow.xaml, cause I’m doing a small project where

  • 0

I deleted the CodeBehind of my MainWindow.xaml, cause I’m doing a small project where I literally must do that.

So I’m creating an instance of my ViewModel in this way over xaml:

<Grid.DataContext>
    <lib:StartPageViewModel />
</Grid.DataContext>

Well now, I need this DataContext in my Code (StartPageViewModel), as I want to open an other solution (For more Informations take a look here).

Any Ideas, on how I can get this DataContext?

  • 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-06-11T03:08:13+00:00Added an answer on June 11, 2026 at 3:08 am

    At least I solved the problem.
    Actually I didn’t really need to use the DataContext for this:

        public static DTE2 GetDTE(DataContext dataContext)
        {
            ICustomTypeDescriptor typeDescriptor = dataContext as ICustomTypeDescriptor;
            Debug.Assert(typeDescriptor != null, "Could not get ICustomTypeDescriptor from dataContext. Was the Start Page tool window DataContext overwritten?");
            PropertyDescriptorCollection propertyCollection = typeDescriptor.GetProperties();
            return propertyCollection.Find("DTE", false).GetValue(dataContext) as DTE2;
        }
    

    I changed the code to the following, it works now perfectly, I can open Solutions without using the DataContext:

        public static DTE2 GetDTE()
        {
            return (DTE2)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE");
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have noticed that deleted branches in svn is not preserved in git. I
I have a gridview that I databind dynamically in my codebehind. For some reason,
I deleted python .pyc files from my local repo and what I thought I
I deleted a table in SQL Server Management Studio. And then I created a
I deleted my old post as it contained a lot of spam. And I
I deleted my prior question dealing with the subject as the context has changed
I deleted the Xcode file in the applications folder and empty the trash. I
I have deleted all <a href=></a> tags in my blog with this regex expression:
Inspired by a now-deleted question; given a regex with named groups, is there a
I accidentally deleted my bookmarked query in phpMyAdmin. Is there any way it can

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.