可移动Mahapps SimpleChildWindow

时间:2019-05-15 20:24:20

标签: c# wpf mahapps.metro

我正在使用Mahapps.Metro.SimpleChildWindow来显示数据输入窗口。我希望输入窗口是可移动的。我在XAML标记中设置了“ AllowMove”,但是窗口仍然无法移动。这是我正在使用的XAML:

<UserControl x:Class="Project.Views.View"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"             
             xmlns:Controls="http://metro.mahapps.com/winfx/xaml/controls"
             xmlns:Dialog="clr-namespace:MahApps.Metro.Controls.Dialogs;assembly=MahApps.Metro"
             xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
             xmlns:simpleChildWindow="clr-namespace:MahApps.Metro.SimpleChildWindow;assembly=MahApps.Metro.SimpleChildWindow"             
             Dialog:DialogParticipation.Register="{Binding}"
             mc:Ignorable="d"
             d:DesignHeight="450" d:DesignWidth="800">

    <Grid x:Name="RootGrid">
        <simpleChildWindow:ChildWindow CloseByEscape="True"
                                       ChildWindowWidth="500"
                                       ChildWindowHeight="200"
                                       HorizontalContentAlignment="Stretch"
                                       VerticalContentAlignment="Stretch"
                                       HorizontalAlignment="Center"
                                       VerticalAlignment="Center"
                                       Margin="10"
                                       ChildWindowImage="None"
                                       BorderBrush="{DynamicResource AccentBaseColorBrush}"
                                       GlowBrush="{DynamicResource AccentColorBrush}"
                                       IsModal="True"
                                       AllowMove="True"
                                       IsOpen="{Binding IsChildWindowOpen}"
                                       Title="View/Edit ">
            <Grid>

                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>

                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="15" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <!-- Child Window Content -->
            </Grid>
        </simpleChildWindow:ChildWindow>
        <-- Other controls and stuff -->
    </Grid>
</UserControl>

我通过将IsChildWindowOpen设置为true或false从ViewModel打开和关闭子窗口。

我一直在查看examples on GitHub,但是带有可移动窗口的示例使用的是外部文件中的XAML。我正在使用嵌套在当前视图中的XAML,以便可以绑定到当前的ViewModel实例。

要使窗口可移动,我需要更改什么?

1 个答案:

答案 0 :(得分:0)

好的,我知道了。我需要删除

>> p.coeff(x**249)
250
窗口声明中的

HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
HorizontalAlignment="Center"
VerticalAlignment="Center"