Window.ShowActivated Property (System.Windows)

Switch View :
ScriptFree
.NET Framework Class Library
Window.ShowActivated Property

Gets or sets a value that indicates whether a window is activated when first shown.

Namespace:  System.Windows
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
Syntax

Visual Basic
Public Property ShowActivated As Boolean
	Get
	Set
C#
public bool ShowActivated { get; set; }
Visual C++
public:
property bool ShowActivated {
	bool get ();
	void set (bool value);
}
F#
member ShowActivated : bool with get, set

XAML Attribute Usage
<object ShowActivated="bool" .../>

Property Value

Type: System.Boolean
true if a window is activated when first shown; otherwise, false. The default is true.
Dependency Property Information

Identifier field

ShowActivatedProperty

Metadata properties set to true

None

Remarks

When a window with its ShowActivated property set to false is opened, the window is not activated and its Activated event is not raised until a user manually activates the window by selecting it. After the window is selected, it activates and deactivates normally.

To prevent a window from being activated when it opens, the ShowActivated property must be set to false before the window is shown (by calling Show); setting ShowActivated to false after a window is shown has no effect.

Setting ShowActivated to false on a window that is opened modally, by calling ShowDialog, has no real impact. Although the modal window will not be activated, the modal window will prevent the user from activating any other open application windows.

Examples

The following example shows how to use markup to configure a window to be opened without being activated.

XAML

<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="WindowShowActivatedSnippets.AWindow"
    ShowActivated="False">


Visual Basic


Imports System.Windows ' Window

Namespace WindowShowActivatedSnippets
    Partial Public Class AWindow
        Inherits Window
        Public Sub New()
            InitializeComponent()
        End Sub
    End Class
End Namespace


C#

using System.Windows; // Window

namespace WindowShowActivatedSnippets
{
    public partial class AWindow : Window
    {
        public AWindow()
        {
            InitializeComponent();
        }
    }
}


The following example shows how to use code to configure a window to be opened without it being activated.

Visual Basic

Dim window As New AWindow()
window.ShowActivated = False
window.Show()


C#

AWindow window = new AWindow();
window.ShowActivated = false;
window.Show();


Version Information

.NET Framework

Supported in: 4, 3.5 SP1, 3.0 SP2

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Platforms

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
See Also

Reference

Other Resources