diff --git a/SourceCode/SharedResources/Panuon.WPF.UI.Internal/Styles/ToastStyle.xaml b/SourceCode/SharedResources/Panuon.WPF.UI.Internal/Styles/ToastStyle.xaml
index f3a684fb..595db3da 100644
--- a/SourceCode/SharedResources/Panuon.WPF.UI.Internal/Styles/ToastStyle.xaml
+++ b/SourceCode/SharedResources/Panuon.WPF.UI.Internal/Styles/ToastStyle.xaml
@@ -38,43 +38,41 @@
Value="2" />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/SourceCode/SharedResources/Panuon.WPF.UI/Configurations/ToastSetting.cs b/SourceCode/SharedResources/Panuon.WPF.UI/Configurations/ToastSetting.cs
index a5b09f4e..3749c3ce 100644
--- a/SourceCode/SharedResources/Panuon.WPF.UI/Configurations/ToastSetting.cs
+++ b/SourceCode/SharedResources/Panuon.WPF.UI/Configurations/ToastSetting.cs
@@ -9,7 +9,8 @@ public class ToastSetting
#region Ctor
public ToastSetting()
{
- LabelStyle = (Style)Application.Current.FindResource(Toast.LabelStyleKey);
+ SetCurrentValue(LabelStyleProperty, (Style)Application.Current.FindResource(Toast.LabelStyleKey));
+ SetCurrentValue(ContentTemplateProperty, (DataTemplate)Application.Current.FindResource(Toast.ContentTemplateKey));
}
#endregion
@@ -26,6 +27,17 @@ public Style LabelStyle
DependencyProperty.Register("LabelStyle", typeof(Style), typeof(ToastSetting));
#endregion
+ #region ContentTemplate
+ public DataTemplate ContentTemplate
+ {
+ get { return (DataTemplate)GetValue(ContentTemplateProperty); }
+ set { SetValue(ContentTemplateProperty, value); }
+ }
+
+ public static readonly DependencyProperty ContentTemplateProperty =
+ DependencyProperty.Register("ContentTemplate", typeof(DataTemplate), typeof(ToastSetting));
+ #endregion
+
#region DefaultPosition
public ToastPosition DefaultPosition
{
diff --git a/SourceCode/SharedResources/Panuon.WPF.UI/Controls/WindowX.cs b/SourceCode/SharedResources/Panuon.WPF.UI/Controls/WindowX.cs
index 0d3ded1a..7f618364 100644
--- a/SourceCode/SharedResources/Panuon.WPF.UI/Controls/WindowX.cs
+++ b/SourceCode/SharedResources/Panuon.WPF.UI/Controls/WindowX.cs
@@ -737,7 +737,8 @@ internal void CallToast(string message,
{
Icon = icon,
Message = message,
- }
+ },
+ ContentTemplate = setting.ContentTemplate,
};
_toastCanvas.Children.Add(label);
diff --git a/SourceCode/SharedResources/Panuon.WPF.UI/Helpers/MessageBoxXSettings.cs b/SourceCode/SharedResources/Panuon.WPF.UI/Helpers/MessageBoxXSettings.cs
index 547f2f28..3bf19daa 100644
--- a/SourceCode/SharedResources/Panuon.WPF.UI/Helpers/MessageBoxXSettings.cs
+++ b/SourceCode/SharedResources/Panuon.WPF.UI/Helpers/MessageBoxXSettings.cs
@@ -89,7 +89,6 @@ public Style WindowXStyle
#endregion
-
#region ContentTemplate
public DataTemplate ContentTemplate
{
diff --git a/SourceCode/SharedResources/Panuon.WPF.UI/Helpers/Toast.cs b/SourceCode/SharedResources/Panuon.WPF.UI/Helpers/Toast.cs
index 36bc6a9a..f28d86ab 100644
--- a/SourceCode/SharedResources/Panuon.WPF.UI/Helpers/Toast.cs
+++ b/SourceCode/SharedResources/Panuon.WPF.UI/Helpers/Toast.cs
@@ -11,6 +11,9 @@ public static class Toast
#region ComponentResourceKeys
public static ComponentResourceKey LabelStyleKey { get; } =
new ComponentResourceKey(typeof(Toast), nameof(LabelStyleKey));
+
+ public static ComponentResourceKey ContentTemplateKey { get; } =
+ new ComponentResourceKey(typeof(Toast), nameof(ContentTemplateKey));
#endregion
#region Methods
@@ -154,24 +157,17 @@ private static WindowX GetTargetWindow(ToastWindow window)
{
return windowX;
}
- throw new ArgumentException("Toast : The main window in Application.Current is null, or the window is not of type Panuon.WPF.UI.WindowX. Please try to specify window parameter for Toast method.");
+ throw new InvalidOperationException("Toast can only be displayed on a window of type 'Panuon.WPF.UI.WindowX'. The value of 'Application.Current.MainWindow' is null, or its type is not 'WindowX'. To specify a different window for the Toast, use the overloaded methods that include a 'window' or 'targetWindow' parameter.");
default:
foreach (var loopObj in Application.Current.Windows)
{
- if (loopObj is Window loopWindow
- && loopWindow.IsActive)
+ if (loopObj is WindowX loopWindowX
+ && loopWindowX.IsActive)
{
- if (loopWindow is WindowX)
- {
- return loopWindow as WindowX;
- }
- else
- {
- break;
- }
+ return loopWindowX;
}
}
- throw new ArgumentException("Toast : The activated window cannot be found in Application.Current, or the window is not of type Panuon.WPF.UI.WindowX. Please try to specify window parameter for Toast method.");
+ throw new InvalidOperationException("Toast can only be displayed on a window of type 'Panuon.WPF.UI.WindowX'. There is no active window, or the active window is not of type 'WindowX'. To specify a different window for the Toast, use the overloaded methods that include a 'window' or 'targetWindow' parameter.");
}
}
#endregion
diff --git a/SourceCode/SharedResources/Panuon.WPF.UI/Helpers/ToastSettings.cs b/SourceCode/SharedResources/Panuon.WPF.UI/Helpers/ToastSettings.cs
index 0b20ddee..d08e7817 100644
--- a/SourceCode/SharedResources/Panuon.WPF.UI/Helpers/ToastSettings.cs
+++ b/SourceCode/SharedResources/Panuon.WPF.UI/Helpers/ToastSettings.cs
@@ -33,6 +33,20 @@ public Style LabelStyle
}
#endregion
+ #region ContentTemplate
+ public DataTemplate ContentTemplate
+ {
+ get
+ {
+ return Setting.ContentTemplate;
+ }
+ set
+ {
+ Setting.ContentTemplate = value;
+ }
+ }
+ #endregion
+
#region Spacing
public double Spacing
{
diff --git a/SourceCode/SharedResources/Panuon.WPF.UI/Properties/AssemblyInfo.cs b/SourceCode/SharedResources/Panuon.WPF.UI/Properties/AssemblyInfo.cs
index 5118c28c..f1d05ffd 100644
--- a/SourceCode/SharedResources/Panuon.WPF.UI/Properties/AssemblyInfo.cs
+++ b/SourceCode/SharedResources/Panuon.WPF.UI/Properties/AssemblyInfo.cs
@@ -25,5 +25,5 @@
ResourceDictionaryLocation.SourceAssembly
)]
-[assembly: AssemblyVersion("1.2.1.4")]
-[assembly: AssemblyFileVersion("1.2.1.4")]
\ No newline at end of file
+[assembly: AssemblyVersion("1.2.1.5")]
+[assembly: AssemblyFileVersion("1.2.1.5")]
\ No newline at end of file