我遇到了相同的问题,通过这些评论,我找到了解决方法。
我使用Prism 6
1)首先重写PopupWindowAction。
protected override Window CreateWindow()
private new Window CreateDefaultWindow(INotification notification)
;
}
else
;
}
return window;
}
protected override Window GetWindow(INotification notification)
else
if (WindowStyle != null)
wrapperWindow.Style = WindowStyle;
return wrapperWindow;
}
2) 创建您的MetroWindow、MetroNotificationWindow和MetroConfirmationWindow,基于默认窗口
例如:
MetroPopupWindow.xaml
<controls:MetroWindow x:Class="MetroPopupWindow"
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:controls="http://metro.mahapps.com/winfx/xaml/controls"
mc:Ignorable="d"
Title="MetroPopupWindow" TitleCaps="False" SizeToContent="WidthAndHeight">
<Grid>
<ContentControl HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="0"
Content="{Binding Content}" />
</Grid>
</controls:MetroWindow>
MetroNotificationWindow.xaml
<controls:MetroWindow x:Class="MetroNotificationWindow"
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:controls="http://metro.mahapps.com/winfx/xaml/controls"
Title="Web Studio" TitleCaps="False" SizeToContent="WidthAndHeight">
<Grid x:Name="LayoutRoot" Margin="5">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ContentControl HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="0"
Content="{Binding Content}" />
<Button x:Name="OKButton" Content="{lex:Loc Ok}" Width="75" Height="25" HorizontalAlignment="Right"
Margin="0,10,0,0" Grid.Row="1" Click="OKButton_Click" IsDefault="True" />
</Grid>
</controls:MetroWindow>
3) 将所有PopupWindowAction的引用更改为MetroPopupWindowAction
例如:
<i:Interaction.Triggers>
<!-- Trigger listening for the "Raised" event on the source object (of type IInteractionRequest) -->
<interactionRequest:InteractionRequestTrigger
SourceObject="{Binding SaveChangesConfirmationRequest, Mode=OneWay}">
<!-- That window will be show as a modal dialog and centered over this window -->
<windowAction:MetroPopupWindowAction IsModal="True" CenterOverAssociatedObject="True" />
</interactionRequest:InteractionRequestTrigger>
</i:Interaction.Triggers>
Window
中,这个Window
可能是由Prism自动创建的。 - Tomasz