Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add delegate to customize external dialog window #3550

Merged
merged 2 commits into from Jul 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -239,9 +239,9 @@
OnLabel="Enabled"
Style="{StaticResource MahApps.Metro.Styles.ToggleSwitch.Win10}" />
<Controls:ToggleSwitch x:Name="visibleSwitch"
Controls:ValidationHelper.ShowValidationErrorOnMouseOver="True"
Controls:ValidationHelper.CloseOnMouseLeftButtonDown="True"
Margin="{StaticResource ControlMargin}"
Controls:ValidationHelper.CloseOnMouseLeftButtonDown="True"
Controls:ValidationHelper.ShowValidationErrorOnMouseOver="True"
IsChecked="{Binding IsToggleSwitchVisible, ValidatesOnDataErrors=True}"
OffLabel="Collapsed"
OnLabel="Visible"
Expand Down
10 changes: 8 additions & 2 deletions src/MahApps.Metro/Controls/Dialogs/DialogManager.cs
Expand Up @@ -538,11 +538,14 @@ private static void RemoveDialog(this MetroWindow window, BaseMetroDialog dialog
/// </summary>
/// <param name="dialog">The dialog which will be shown externally.</param>
/// <param name="windowOwner">The owner for the external window. If it's null the main window will be use.</param>
/// <param name="handleExternalDialogWindow">The delegate for customizing dialog window. It can be null.</param>
/// <returns>The given dialog.</returns>
public static BaseMetroDialog ShowDialogExternally(this BaseMetroDialog dialog, [CanBeNull] Window windowOwner = null)
public static BaseMetroDialog ShowDialogExternally(this BaseMetroDialog dialog, [CanBeNull] Window windowOwner = null, [CanBeNull] Action<Window> handleExternalDialogWindow = null)
{
Window win = SetupExternalDialogWindow(dialog, windowOwner);

handleExternalDialogWindow?.Invoke(win);

dialog.OnShown();
win.Show();

Expand All @@ -554,11 +557,14 @@ public static BaseMetroDialog ShowDialogExternally(this BaseMetroDialog dialog,
/// </summary>
/// <param name="dialog">The dialog which will be shown externally.</param>
/// <param name="windowOwner">The owner for the external window. If it's null the main window will be use.</param>
/// <param name="handleExternalDialogWindow">The delegate for customizing dialog window. It can be null.</param>
/// <returns>The given dialog.</returns>
public static BaseMetroDialog ShowModalDialogExternally(this BaseMetroDialog dialog, [CanBeNull] Window windowOwner = null)
public static BaseMetroDialog ShowModalDialogExternally(this BaseMetroDialog dialog, [CanBeNull] Window windowOwner = null, [CanBeNull] Action<Window> handleExternalDialogWindow = null)
{
Window win = SetupExternalDialogWindow(dialog, windowOwner);

handleExternalDialogWindow?.Invoke(win);

dialog.OnShown();
win.ShowDialog();

Expand Down
6 changes: 1 addition & 5 deletions src/MahApps.Metro/Controls/Dialogs/InputDialog.xaml
Expand Up @@ -26,18 +26,14 @@
TextWrapping="Wrap" />

<StackPanel Grid.Row="2"
Height="85"
MinHeight="85"
HorizontalAlignment="Right"
Orientation="Horizontal">
<Button x:Name="PART_AffirmativeButton"
Height="35"
MinWidth="80"
Margin="0 0 5 0"
Content="{Binding AffirmativeButtonText, RelativeSource={RelativeSource AncestorType=Dialogs:InputDialog, Mode=FindAncestor}, UpdateSourceTrigger=PropertyChanged}"
Style="{DynamicResource MahApps.Metro.Styles.Dialogs.AccentButton}" />
<Button x:Name="PART_NegativeButton"
Height="35"
MinWidth="80"
Margin="5 0 5 0"
Content="{Binding NegativeButtonText, RelativeSource={RelativeSource AncestorType=Dialogs:InputDialog, Mode=FindAncestor}, UpdateSourceTrigger=PropertyChanged}"
Style="{DynamicResource MahApps.Metro.Styles.Dialogs.Button}" />
Expand Down
6 changes: 1 addition & 5 deletions src/MahApps.Metro/Controls/Dialogs/LoginDialog.xaml
Expand Up @@ -45,18 +45,14 @@
IsChecked="{Binding RememberCheckBoxChecked, RelativeSource={RelativeSource AncestorType=Dialogs:LoginDialog, Mode=FindAncestor}, UpdateSourceTrigger=PropertyChanged}"
Visibility="{Binding RememberCheckBoxVisibility, RelativeSource={RelativeSource AncestorType=Dialogs:LoginDialog, Mode=FindAncestor}, UpdateSourceTrigger=PropertyChanged}" />
<StackPanel Grid.Row="4"
Height="85"
MinHeight="85"
HorizontalAlignment="Right"
Orientation="Horizontal">
<Button x:Name="PART_AffirmativeButton"
Height="35"
MinWidth="80"
Margin="0 0 5 0"
Content="{Binding AffirmativeButtonText, RelativeSource={RelativeSource AncestorType=Dialogs:LoginDialog, Mode=FindAncestor}, UpdateSourceTrigger=PropertyChanged}"
Style="{DynamicResource MahApps.Metro.Styles.Dialogs.AccentButton}" />
<Button x:Name="PART_NegativeButton"
Height="35"
MinWidth="80"
Margin="5 0 5 0"
Content="{Binding NegativeButtonText, RelativeSource={RelativeSource AncestorType=Dialogs:LoginDialog, Mode=FindAncestor}, UpdateSourceTrigger=PropertyChanged}"
Style="{DynamicResource MahApps.Metro.Styles.Dialogs.Button}"
Expand Down
10 changes: 1 addition & 9 deletions src/MahApps.Metro/Controls/Dialogs/MessageDialog.xaml
Expand Up @@ -24,31 +24,23 @@
</ScrollViewer>

<StackPanel Grid.Row="1"
Height="85"
MinHeight="85"
HorizontalAlignment="Right"
Orientation="Horizontal">
<Button x:Name="PART_AffirmativeButton"
Height="35"
MinWidth="80"
Margin="0 0 5 0"
Content="{Binding AffirmativeButtonText, RelativeSource={RelativeSource AncestorType=Dialogs:MessageDialog, Mode=FindAncestor}, UpdateSourceTrigger=PropertyChanged}"
Style="{DynamicResource MahApps.Metro.Styles.Dialogs.Button}" />
<Button x:Name="PART_NegativeButton"
Height="35"
MinWidth="80"
Margin="5 0 5 0"
Content="{Binding NegativeButtonText, RelativeSource={RelativeSource AncestorType=Dialogs:MessageDialog, Mode=FindAncestor}, UpdateSourceTrigger=PropertyChanged}"
Style="{DynamicResource MahApps.Metro.Styles.Dialogs.Button}" />
<Button x:Name="PART_FirstAuxiliaryButton"
Height="35"
MinWidth="80"
Margin="5 0 5 0"
Content="{Binding FirstAuxiliaryButtonText, RelativeSource={RelativeSource AncestorType=Dialogs:MessageDialog, Mode=FindAncestor}, UpdateSourceTrigger=PropertyChanged}"
Style="{DynamicResource MahApps.Metro.Styles.Dialogs.Button}"
Visibility="Collapsed" />
<Button x:Name="PART_SecondAuxiliaryButton"
Height="35"
MinWidth="80"
Margin="5 0 0 0"
Content="{Binding SecondAuxiliaryButtonText, RelativeSource={RelativeSource AncestorType=Dialogs:MessageDialog, Mode=FindAncestor}, UpdateSourceTrigger=PropertyChanged}"
Style="{DynamicResource MahApps.Metro.Styles.Dialogs.Button}"
Expand Down
4 changes: 1 addition & 3 deletions src/MahApps.Metro/Controls/Dialogs/ProgressDialog.xaml
Expand Up @@ -18,12 +18,10 @@
TextWrapping="Wrap" />

<StackPanel Grid.Row="1"
Height="85"
MinHeight="85"
HorizontalAlignment="Right"
Orientation="Horizontal">
<Button x:Name="PART_NegativeButton"
Height="35"
MinWidth="80"
Margin="5 0 0 0"
Content="{Binding NegativeButtonText, RelativeSource={RelativeSource AncestorType=Dialogs:ProgressDialog, Mode=FindAncestor}, UpdateSourceTrigger=PropertyChanged}"
Cursor="Arrow"
Expand Down
9 changes: 9 additions & 0 deletions src/MahApps.Metro/Themes/Dialogs/BaseMetroDialog.xaml
Expand Up @@ -10,18 +10,27 @@
<Style x:Key="MahApps.Metro.Styles.Dialogs.Button"
BasedOn="{StaticResource SquareButtonStyle}"
TargetType="{x:Type Button}">
<Setter Property="MinHeight" Value="35" />
<Setter Property="MinWidth" Value="80" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="controls:ControlsHelper.ContentCharacterCasing" Value="Normal" />
</Style>

<Style x:Key="MahApps.Metro.Styles.Dialogs.AccentButton"
BasedOn="{StaticResource AccentedSquareButtonStyle}"
TargetType="{x:Type ButtonBase}">
<Setter Property="MinHeight" Value="35" />
<Setter Property="MinWidth" Value="80" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="controls:ControlsHelper.ContentCharacterCasing" Value="Normal" />
</Style>

<Style x:Key="MahApps.Metro.Styles.Dialogs.AccentHighlightButton"
BasedOn="{StaticResource HighlightedSquareButtonStyle}"
TargetType="{x:Type ButtonBase}">
<Setter Property="MinHeight" Value="35" />
<Setter Property="MinWidth" Value="80" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="controls:ControlsHelper.ContentCharacterCasing" Value="Normal" />
</Style>

Expand Down