punker76 / MahApps.Metro.SimpleChildWindow

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

Strange things happen if window devided by grid rows. #77

Closed DeputyOfCopyPaster closed 6 years ago

DeputyOfCopyPaster commented 6 years ago

Hello there, I am a newcomer, just testing 'SimpleChildWindow' for my needs.

I faced with a stuff as follows:

mahapps_window_with_no_grid That's working properly. I used this method:

 private async void button_Click(object sender, RoutedEventArgs e)
        {
            await this.ShowChildWindowAsync(new Parameter_01() { IsModal = true, AllowMove = true }, RootGrid);
        }

mahapps_window_with_grid Just I added the needed rows in the 'Rootgrid'. And everything became bad. Could someone make some comments on this, I don't know, if this is an issue.

Thanks in advance.

punker76 commented 6 years ago

@DeputyOfCopyPaster Please can you post your grid layout? it seems like your Rootgrid is not any more the "root" grid.

DeputyOfCopyPaster commented 6 years ago

@DeputyOfCopyPaster Please can you post your grid layout? it seems like your Rootgrid is not any more the "root" grid.

Yes, of course!

<Controls:MetroWindow
    x:Class="MahappsChildWindowTest_01.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:local="clr-namespace:MahappsChildWindowTest_01"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    Title="MainWindow"
    Width="800"
    Height="600"
    MinWidth="800"
    MinHeight="600"
    mc:Ignorable="d">

    <Grid x:Name="RootGrid" ShowGridLines="True">

            <Grid.RowDefinitions>
            <RowDefinition Height="80" />
            <RowDefinition Height="*" />
            <RowDefinition Height="200" />
            </Grid.RowDefinitions> 

        <Button x:Name="button" Content="Result" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Click="button_Click" Margin="550,79,0,0" Grid.Row="2"  />

    </Grid>
</Controls:MetroWindow>

It seems, I have a single grid.

DeputyOfCopyPaster commented 6 years ago

Solved! If you're going to use 'SimpleChildWindow', don't use that grid that comes by default by a project creating. You must leave default grid to be virgin. In default grid can be next grid which may be formatted by you. Otherwise you will get an issue as described above. There's nothing about in the stricted manuals to this masterpiece, though.

This is wrong approach:

<Grid x:Name="RootGrid" ShowGridLines="True"> <!--default grid-->

            <Grid.RowDefinitions>
            <RowDefinition Height="80" />
            <RowDefinition Height="*" />
            <RowDefinition Height="200" />
            </Grid.RowDefinitions> 

</Grid > <!-- default grid-->

This is approach that solved issue:

<Grid x:Name="RootGrid" >  <!-- default grid-->
<Grid ShowGridLines="True">  <!-- a grid to be formatted for your needs-->

            <Grid.RowDefinitions>
            <RowDefinition Height="80" />
            <RowDefinition Height="*" />
            <RowDefinition Height="200" />
            </Grid.RowDefinitions> 

</Grid > <!-- a grid to be formatted for your needs-->
</Grid> <!-- default grid-->

Solved thanks to Punker76's a little hint about.