Window.ShowActivated Property
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets a value that indicates whether a window is activated when first shown.
public:
property bool ShowActivated { bool get(); void set(bool value); };
public bool ShowActivated { get; set; }
member this.ShowActivated : bool with get, set
Public Property ShowActivated As Boolean
true
if a window is activated when first shown; otherwise, false
. The default is true
.
The following example shows how to use markup to configure a window to be opened without being activated.
<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">
using System.Windows;
namespace WindowShowActivatedSnippets
{
public partial class AWindow : Window
{
public AWindow()
{
InitializeComponent();
}
}
}
Imports System.Windows
Namespace WindowShowActivatedSnippets
Partial Public Class AWindow
Inherits Window
Public Sub New()
InitializeComponent()
End Sub
End Class
End Namespace
The following example shows how to use code to configure a window to be opened without it being activated.
AWindow window = new AWindow();
window.ShowActivated = false;
window.Show();
Dim window As New AWindow()
window.ShowActivated = False
window.Show()
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.
Identifier field | ShowActivatedProperty |
Metadata properties set to true |
None |
Product | Versions |
---|---|
.NET Framework | 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: