I'm using Prism in a WPF project. I implemented a Dialog Service, as suggested in the Prism web site (here)
I have a MainWindow in charge of calling the "_dialogService.ShowDialog(...)" method on request.
Everything seems to work fine, except one thing (unfortunately!): The program runs in a resizable window (not full screen) with a defined size, let's say 1600x900 but it doesn't matter. If I resize the window (i.e. to increase the size), next time I open the dialog , it's no more centered. It keeps the "centered position" of the initial window size, but it doesn't recalculate it after the window resize.
Can anybody help me to find a way to fix this behaviour?
Here's the code used in the UserControl:
<prism:Dialog.WindowStyle>
<Style TargetType="Window">
<Setter Property="prism:Dialog.WindowStartupLocation" Value="CenterScreen" />
<Setter Property="ResizeMode" Value="NoResize"/>
<Setter Property="ShowInTaskbar" Value="False"/>
<Setter Property="SizeToContent" Value="WidthAndHeight"/>
<Setter Property="BorderThickness" Value="0" />
<Setter Property="WindowStyle" Value="None" />
</Style>
</prism:Dialog.WindowStyle>
And here's the parts in the MainWindowViewModel.cs
public MainWindowViewModel(IRegionManager regionManager, IEventAggregator ea, IDialogService dialogService)
{
_regionManager = regionManager;
_ea = ea;
_dialogService = dialogService;
}
private void ShowDialog(DialogData data)
{
_dialogService.ShowDialog("DlgConfirmDialog", new DialogParameters($"title={data.Title}&message={data.Message}), r =>
{
//do something
});
}