Skip to content

Commit 130df90

Browse files
committed
allow dialog content to be updated
1 parent a96f9cd commit 130df90

File tree

3 files changed

+11
-17
lines changed

3 files changed

+11
-17
lines changed

MaterialDesignThemes.Wpf/Converters/BrushRoundConverter.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@ public class BrushRoundConverter : IValueConverter
1313
public Brush LowValue { get; set; } = Brushes.Black;
1414

1515
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
16-
{
16+
{
1717
var solidColorBrush = value as SolidColorBrush;
1818
if (solidColorBrush == null) return Binding.DoNothing;
1919

20-
2120
var color = solidColorBrush.Color;
2221

2322
var brightness = 0.3 * color.R + 0.59 * color.G + 0.11 * color.B;

MaterialDesignThemes.Wpf/DialogHost.cs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ public class DialogHost : ContentControl
3232

3333
private Popup _popup;
3434
private Window _window;
35-
private DialogClosingEventHandler _attachedDialogClosingEventHandler;
36-
private bool _removeContentOnClose;
35+
private DialogClosingEventHandler _attachedDialogClosingEventHandler;
3736
private object _closeDialogExecutionParameter = null;
3837

3938
static DialogHost()
@@ -85,7 +84,6 @@ public static async Task<object> Show(object content, object dialogIndetifier, D
8584

8685
await task;
8786

88-
targets[0].DialogContent = null;
8987
targets[0]._asyncShowClosingEventHandler = null;
9088

9189
return targets[0]._closeDialogExecutionParameter;
@@ -126,11 +124,6 @@ private static void IsOpenPropertyChangedCallback(DependencyObject dependencyObj
126124
{
127125
dialogHost._asyncShowWaitHandle.Set();
128126
dialogHost._attachedDialogClosingEventHandler = null;
129-
if (dialogHost._removeContentOnClose)
130-
{
131-
dialogHost.DialogContent = null;
132-
dialogHost._removeContentOnClose = false;
133-
}
134127
return;
135128
}
136129

@@ -257,7 +250,6 @@ private void OpenDialogHandler(object sender, ExecutedRoutedEventArgs executedRo
257250
{
258251
AssertTargetableContent();
259252
DialogContent = executedRoutedEventArgs.Parameter;
260-
_removeContentOnClose = true;
261253
}
262254

263255
SetCurrentValue(IsOpenProperty, true);
@@ -268,9 +260,9 @@ private void OpenDialogHandler(object sender, ExecutedRoutedEventArgs executedRo
268260
private void AssertTargetableContent()
269261
{
270262
var existindBinding = BindingOperations.GetBindingExpression(this, DialogContentProperty);
271-
if (existindBinding != null || DialogContent != null)
263+
if (existindBinding != null)
272264
throw new InvalidOperationException(
273-
"Content cannot be passed to a dialog via the OpenDialog of DialogContent is already set, or has a binding.");
265+
"Content cannot be passed to a dialog via the OpenDialog if DialogContent already has a binding.");
274266
}
275267

276268
private void CloseDialogHandler(object sender, ExecutedRoutedEventArgs executedRoutedEventArgs)

MaterialDesignThemes.Wpf/Themes/Generic.xaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@
484484
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="CardScaleTransform" Storyboard.TargetProperty="ScaleX">
485485
<EasingDoubleKeyFrame Value="1" KeyTime="0" />
486486
<EasingDoubleKeyFrame Value="1" KeyTime="0:0:0.18" />
487-
<EasingDoubleKeyFrame Value="0" KeyTime="0:0:0.3">
487+
<EasingDoubleKeyFrame Value="0.5" KeyTime="0:0:0.3">
488488
<EasingDoubleKeyFrame.EasingFunction>
489489
<SineEase EasingMode="EaseInOut" />
490490
</EasingDoubleKeyFrame.EasingFunction>
@@ -493,7 +493,7 @@
493493
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="CardScaleTransform" Storyboard.TargetProperty="ScaleY">
494494
<EasingDoubleKeyFrame Value="1" KeyTime="0" />
495495
<EasingDoubleKeyFrame Value="1" KeyTime="0:0:0.18" />
496-
<EasingDoubleKeyFrame Value="0" KeyTime="0:0:0.3">
496+
<EasingDoubleKeyFrame Value="0.5" KeyTime="0:0:0.3">
497497
<EasingDoubleKeyFrame.EasingFunction>
498498
<SineEase EasingMode="EaseInOut" />
499499
</EasingDoubleKeyFrame.EasingFunction>
@@ -519,12 +519,15 @@
519519
</VisualState>
520520
<VisualState x:Name="Closed">
521521
<Storyboard>
522-
522+
<BooleanAnimationUsingKeyFrames Storyboard.TargetName="PART_Popup" Storyboard.TargetProperty="IsOpen">
523+
<DiscreteBooleanKeyFrame Value="True" KeyTime="0:0:0" />
524+
<DiscreteBooleanKeyFrame Value="False" KeyTime="0:0:0.3" />
525+
</BooleanAnimationUsingKeyFrames>
523526
</Storyboard>
524527
</VisualState>
525528
</VisualStateGroup>
526529
</VisualStateManager.VisualStateGroups>
527-
<Popup IsOpen="False" StaysOpen="True" AllowsTransparency="True"
530+
<Popup IsOpen="False" StaysOpen="True" AllowsTransparency="True" PopupAnimation="None"
528531
x:Name="PART_Popup"
529532
Placement="Center">
530533
<Popup.Resources>

0 commit comments

Comments
 (0)