【发布时间】:2015-07-28 14:30:16
【问题描述】:
我有一个带有已定义网格的现有 WPF MainWindow.xaml。在其中一个网格字段中有一个按钮,它打开以下“ChildWindow”:
<Controls:MetroWindow x:Class="RFM_data_analyzer.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:oxy="http://oxyplot.org/wpf"
xmlns:local="clr-namespace:WpfApplication1"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:simpleChildWindow="clr-namespace:MahApps.Metro.SimpleChildWindow;assembly=MahApps.Metro.SimpleChildWindow"
Title="RFM data analyzer (WPF)"
WindowStyle="ThreeDBorderWindow" ResizeMode="CanResize"
WindowStartupLocation="CenterScreen" WindowState="Maximized" Height="855" Width="1024">
<Window.DataContext>
<local:MainViewModel/>
</Window.DataContext>
<Grid>
<!-- Definition of Rows and Columns -->
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="250" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150"/>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="250" />
</Grid.ColumnDefinitions>
<!-- Here are some other, uninteresing code lines -->
<simpleChildWindow:ChildWindow x:Name="ChartControllings"
CloseByEscape="False"
ChildWindowWidth="400"
ChildWindowHeight="300"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Padding="1"
ChildWindowImage="Error"
Title="Chart Controllings">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0"
Margin="20"
FontSize="36"
FontWeight="Thin"
Text="awesome!" />
<TextBox Grid.Row="1" />
<Button Grid.Row="2"
Margin="20"
IsDefault="True"
VerticalAlignment="Top"
FontSize="20"
FontWeight="Thin"
Content="Close Me"/>
</Grid>
</simpleChildWindow:ChildWindow>
</Grid>
</Controls:MetroWindow>
来源在这里:MahApps.Metro.SimpleChildWindow
如果我在 MainWindow.xaml 的网格区域中包含代码,如上所示,默认情况下该窗口在 Grid.Row="0" Grid.Column="0" 中打开,而不是在屏幕中心与demo project 完全一样。我有两个项目并排,但看不出区别。谁能帮帮我?
谢谢!
【问题讨论】:
标签: wpf mahapps.metro