Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

Window.Project Property

Gets the Project object associated with the Window object.

Namespace: EnvDTE
Assembly: EnvDTE (in envdte.dll)

Project Project { get; }
/** @property */
Project get_Project ()

function get Project () : Project

Property Value

A Project object.

The Project property represents the project to which the item belongs.

public void CodeExample(DTE2 dte, AddIn addin)
    {   // Before running, create a text file named 
        // "TextFile1.txt", include it in your solution,
        // and make it the active window.
        Window win;
        Document doc;
        if (dte.Documents.Count > 0)
            doc = dte.Documents.Item("TextFile1.txt");
            win = doc.ActiveWindow;
            // Show the name of the project that contains this window and document.
            win.Activate(); // Activate the window
            // Show the name of the current ProjectItem in the window.
            // How many other windows are available?
            string w = "Windows:\n";
            foreach (Window wi in win.Collection)
                w = w + wi.Caption + "\n";
            // Determine that the document returned by the document 
            // property is the same as the document object 'doc'.
            if (win.Document.Equals(doc))
                MessageBox.Show("The documents match!");
            else MessageBox.Show("The documents do not match!");
            // Close the window.
    catch(Exception ex)

Community Additions

© 2015 Microsoft