Skip to content

Commit

Permalink
Merge pull request #3550 from RayMMond/OpenupDialogSettings
Browse files Browse the repository at this point in the history
Add delegate to customize external dialog window
  • Loading branch information
punker76 authored Jul 15, 2019
2 parents 1f793da + 7512b1c commit 47c7d81
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 26 deletions.
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit 47c7d81

Please sign in to comment.