WPF Child Window Disappears When Switching Between Applications (Topmost property set to true overlaps other applications)

‘m working on a WPF desktop application and I’m experiencing an issue with how my child windows behave when switching between applications. Specifically, when I switch to another application using the taskbar and then return to my WPF application, the child window that should be displayed on top of the parent window is not visible. Instead, I see the main application window, and the child window seems to be hidden behind it.

I’ve tried using the Topmost property in WPF XAML to keep the child window on top of other applications, but this results in the child window appearing on top of all other applications, which is not the behavior I want.

I need the child window to stay on top of its parent window within my WPF application. When switching back to my application from another one, I want this specific child window to be visible and on top, blocking the view of the parent window and other controls within the application.

How can I achieve this behavior?

I have tried:
How to make a WPF window be on top of all other windows of my app (not system wide)?

Here is my code in XAML:

<Window x:Class="FactoryConfigWpfViews.Views.ClientMultiServer.AddServerDialogWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    AutomationProperties.AutomationId="AddServerDialogWindow"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    ShowInTaskbar="False"
    Topmost="True"
    WindowStartupLocation="CenterScreen"
    ResizeMode="NoResize"
    mc:Ignorable="d"
    Title="{Binding WindowTitle}" Height="160" Width="450">
<Window.Resources>
    <Style TargetType="Button">
        <Setter Property="Width" Value="100" />
        <Setter Property="Height" Value="22" />
    </Style>
</Window.Resources>
<DockPanel FocusManager.FocusedElement="{Binding ElementName=ServerHostName}">
    <Grid DockPanel.Dock="Top" Margin="10,10,0,0">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.Resources>
            <Style TargetType="TextBox">
                <Setter Property="Margin" Value="5,5,5,5" />
            </Style>
        </Grid.Resources>
        <Label Grid.Row="1" Grid.Column="0" Content="Enter the Server Identifier:" AutomationProperties.AutomationId="AddServerAssignedToClientServerHostnameLabel" Grid.ColumnSpan="2" Margin="0,10,275,-15" />

        <TextBox x:Name="ServerHostName" Grid.Row="1" Grid.Column="1" Text="{Binding Path=ServerHostname, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" AutomationProperties.AutomationId="AddServerAssignedToClientTextBox" Margin="153,12,10,-12"/>
    </Grid>

    <StackPanel DockPanel.Dock="Bottom" VerticalAlignment="Bottom" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,10,10,10">
        <Button Content="OK" HorizontalAlignment="Right" Margin="0,0,10,0" AutomationProperties.AutomationId="AddServerAssignedToClientOkButton" Command="{Binding AddServerAssignedToClient}" CommandParameter="{Binding RelativeSource={RelativeSource AncestorType={x:Type Window}, Mode=FindAncestor}}"
                IsDefault="True"/>
        <Button Content="Cancel" AutomationProperties.AutomationId="AddServerAssignedToClientCancelButton" Command="{Binding CancelAddServer}" CommandParameter="{Binding RelativeSource={RelativeSource AncestorType={x:Type Window}, Mode=FindAncestor}}" 
                IsCancel="True"/>
    </StackPanel>
</DockPanel>

3

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật