punker76 / MahApps.Metro.SimpleChildWindow

A simple child window for MahApps.Metro
MIT License
374 stars 55 forks source link

Multiple Window Childs Focus(Bring To Front) Problem #25

Closed evrend closed 7 years ago

evrend commented 8 years ago

When i create multiple window childs and click on the back window child, It doesn't bring to front the other child. ekran

Details:

Windows 8.1 Visual Studio 2015 Mahapps V.1.1.2.0 Mahapps SimpleChildWindow V.1.2.0.0

<simpleChildWindow:ChildWindow
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:simpleChildWindow="clr-namespace:MahApps.Metro.SimpleChildWindow;assembly=MahApps.Metro.SimpleChildWindow"
        xmlns:local="clr-namespace:HerkodOsgb.Moduller.Kullanicilar.Views"  
        xmlns:Models="clr-namespace:HerkodOsgb.Models"
        x:Class="HerkodOsgb.Moduller.Kullanicilar.Views.kullanicilar"
        GlowBrush="{DynamicResource AccentColorBrush}"
        BorderBrush="{DynamicResource AccentColorBrush}"
        BorderThickness="1"
        Title="Kullanıcılar"
        ShowCloseButton="True"
        CloseByEscape="True"
    >
    <simpleChildWindow:ChildWindow.Icon>
        <Rectangle Width="22"
                   Height="22"
                   Fill="{DynamicResource IdealForegroundColorBrush}">
            <Rectangle.OpacityMask>
                <VisualBrush Stretch="Uniform"
                             Visual="{DynamicResource appbar_group_add}" />
            </Rectangle.OpacityMask>
        </Rectangle>
    </simpleChildWindow:ChildWindow.Icon>
    <Grid Height="600" Width="1000">

    </Grid>
</simpleChildWindow:ChildWindow>
private async void Kullanicilar(object sender, RoutedEventArgs e)
        {
            await MahApps.Metro.SimpleChildWindow.ChildWindowManager.ShowChildWindowAsync(this, new Moduller.Kullanicilar.Views.kullanicilar() { IsModal = false, AllowMove = true }, RootGrid);
        }
evrend commented 8 years ago

I found a solution but maybe it can be resolved with a basic way?

My Solution, Child Class Code

        private void ChildWindow_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            this.BrintToFront();
        }

        private void ChildWindow_GotMouseCapture(object sender, System.Windows.Input.MouseEventArgs e)
        {
            this.BrintToFront();
        }

        private void BrintToFront()
        {
            var _parent = (Grid)this.Parent;
            _parent.Children.Remove(this);
            int _count = _parent.Children.Count;
            _parent.Children.Insert(_count, this);
        }
punker76 commented 7 years ago

Available in 1.4.0