├── asset ├── icons │ ├── close.png │ ├── danger_16.png │ ├── close-hover.png │ ├── success_16.png │ ├── warning_16.png │ └── information_16.png └── screenshots │ ├── Danger.png │ ├── Success.png │ ├── Warning.png │ ├── WarningB.png │ ├── WarningC.png │ ├── WarningD.png │ ├── Information.png │ └── screenshot1.gif ├── test └── AlertBarWpfExample.zip ├── .gitattributes ├── LICENSE.txt ├── README.md ├── .gitignore └── src ├── AlertBarWpf.xaml ├── AlertBarWpf.csproj └── AlertBarWpf.xaml.cs /asset/icons/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chadkuehn/AlertBarWpf/HEAD/asset/icons/close.png -------------------------------------------------------------------------------- /asset/icons/danger_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chadkuehn/AlertBarWpf/HEAD/asset/icons/danger_16.png -------------------------------------------------------------------------------- /asset/icons/close-hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chadkuehn/AlertBarWpf/HEAD/asset/icons/close-hover.png -------------------------------------------------------------------------------- /asset/icons/success_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chadkuehn/AlertBarWpf/HEAD/asset/icons/success_16.png -------------------------------------------------------------------------------- /asset/icons/warning_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chadkuehn/AlertBarWpf/HEAD/asset/icons/warning_16.png -------------------------------------------------------------------------------- /asset/screenshots/Danger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chadkuehn/AlertBarWpf/HEAD/asset/screenshots/Danger.png -------------------------------------------------------------------------------- /test/AlertBarWpfExample.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chadkuehn/AlertBarWpf/HEAD/test/AlertBarWpfExample.zip -------------------------------------------------------------------------------- /asset/icons/information_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chadkuehn/AlertBarWpf/HEAD/asset/icons/information_16.png -------------------------------------------------------------------------------- /asset/screenshots/Success.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chadkuehn/AlertBarWpf/HEAD/asset/screenshots/Success.png -------------------------------------------------------------------------------- /asset/screenshots/Warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chadkuehn/AlertBarWpf/HEAD/asset/screenshots/Warning.png -------------------------------------------------------------------------------- /asset/screenshots/WarningB.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chadkuehn/AlertBarWpf/HEAD/asset/screenshots/WarningB.png -------------------------------------------------------------------------------- /asset/screenshots/WarningC.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chadkuehn/AlertBarWpf/HEAD/asset/screenshots/WarningC.png -------------------------------------------------------------------------------- /asset/screenshots/WarningD.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chadkuehn/AlertBarWpf/HEAD/asset/screenshots/WarningD.png -------------------------------------------------------------------------------- /asset/screenshots/Information.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chadkuehn/AlertBarWpf/HEAD/asset/screenshots/Information.png -------------------------------------------------------------------------------- /asset/screenshots/screenshot1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chadkuehn/AlertBarWpf/HEAD/asset/screenshots/screenshot1.gif -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Chad Kuehn 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | http://www.opensource.org/licenses/mit-license.php -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Alert Bar WPF UserControl 2 | 3 | This is a WPF usercontrol for displaying user updates through an alert bar. There are four types of alerts: success, danger, warning or information. The color scheme and icons for each are based on the type. 4 | 5 | ![Screenshot 1](https://raw.github.com/chadkuehn/AlertBarWpf/master/asset/screenshots/screenshot1.gif) 6 | 7 | ## Dependencies 8 | - WPF Application 9 | 10 | ## Usage 11 | Download the [archive](https://github.com/chadkuehn/AlertBarWpf/releases/latest) or install the [nuget](https://www.nuget.org/packages/AlertBarWpf/). If you downloaded the archive then in Visual Studio you must go to Solution Explorer » right-click on References » Add a Reference » browse to DLL in the archive bin folder. 12 | 13 | **GUI:** 14 | In the xaml you must reference the namespace to add the usercontrol: 15 | ```html 16 | 18 | ``` 19 | 20 | Using this reference place the control on the form. I typically position this above any other controls: 21 | ```html 22 | 23 | ``` 24 | 25 | An optional `IconVisibility` parameter to remove icons from all alert messages. There is also a `Theme` parameter to adjust the look of the bar: 26 | 27 | ```html 28 | 29 | ``` 30 | 31 | **Code Behind:** 32 | To make use of the control we trigger it in the xaml.cs. Call the methods like so: 33 | ```csharp 34 | msgbar.Clear(); 35 | msgbar.SetDangerAlert("Select an Item."); 36 | ``` 37 | 38 | 39 | ## Features 40 | - Multiple themes 41 | - Recognizable color scheme/icons for danger, success, warning, or information 42 | - Does not occupy space when not in use 43 | - Auto-closes (if desired) 44 | 45 | 46 | ## API 47 | **Methods:** 48 | 49 | - Clear 50 | - SetDangerAlert 51 | - SetSuccessAlert 52 | - SetWarningAlert 53 | - SetInformationAlert 54 | 55 | Each of the creation methods above takes a message parameter and an optional timeout parameter (based on seconds). 56 | 57 | **XAML Properties:** 58 | - Theme 59 | - IconVisibility 60 | 61 | **Themes:** 62 | 63 | - Outline 64 | - Standard 65 | 66 | 67 | 68 | ## Support 69 | Found a bug or have a feature request? [Open an issue](https://github.com/chadkuehn/AlertBarWpf/issues/new ). 70 | 71 | ## Author 72 | **Chad Kuehn** 73 | 74 | ## Copyright & License 75 | Copyright (c) 2014 Chad Kuehn 76 | 77 | AlertBarWpf is available under the MIT license. See the [LICENSE file][7.1] 78 | for more information. 79 | 80 | [7.1]: ./LICENSE.txt 81 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.sln.docstates 8 | 9 | # Build results 10 | [Dd]ebug/ 11 | [Dd]ebugPublic/ 12 | [Rr]elease/ 13 | x64/ 14 | build/ 15 | bld/ 16 | [Bb]in/ 17 | [Oo]bj/ 18 | 19 | # MSTest test Results 20 | [Tt]est[Rr]esult*/ 21 | [Bb]uild[Ll]og.* 22 | 23 | #NUNIT 24 | *.VisualState.xml 25 | TestResult.xml 26 | 27 | # Build Results of an ATL Project 28 | [Dd]ebugPS/ 29 | [Rr]eleasePS/ 30 | dlldata.c 31 | 32 | *_i.c 33 | *_p.c 34 | *_i.h 35 | *.ilk 36 | *.meta 37 | *.obj 38 | *.pch 39 | *.pdb 40 | *.pgc 41 | *.pgd 42 | *.rsp 43 | *.sbr 44 | *.tlb 45 | *.tli 46 | *.tlh 47 | *.tmp 48 | *.tmp_proj 49 | *.log 50 | *.vspscc 51 | *.vssscc 52 | .builds 53 | *.pidb 54 | *.svclog 55 | *.scc 56 | 57 | # Chutzpah Test files 58 | _Chutzpah* 59 | 60 | # Visual C++ cache files 61 | ipch/ 62 | *.aps 63 | *.ncb 64 | *.opensdf 65 | *.sdf 66 | *.cachefile 67 | 68 | # Visual Studio profiler 69 | *.psess 70 | *.vsp 71 | *.vspx 72 | 73 | # TFS 2012 Local Workspace 74 | $tf/ 75 | 76 | # Guidance Automation Toolkit 77 | *.gpState 78 | 79 | # ReSharper is a .NET coding add-in 80 | _ReSharper*/ 81 | *.[Rr]e[Ss]harper 82 | *.DotSettings.user 83 | 84 | # JustCode is a .NET coding addin-in 85 | .JustCode 86 | 87 | # TeamCity is a build add-in 88 | _TeamCity* 89 | 90 | # DotCover is a Code Coverage Tool 91 | *.dotCover 92 | 93 | # NCrunch 94 | *.ncrunch* 95 | _NCrunch_* 96 | .*crunch*.local.xml 97 | 98 | # MightyMoose 99 | *.mm.* 100 | AutoTest.Net/ 101 | 102 | # Web workbench (sass) 103 | .sass-cache/ 104 | 105 | # Installshield output folder 106 | [Ee]xpress/ 107 | 108 | # DocProject is a documentation generator add-in 109 | DocProject/buildhelp/ 110 | DocProject/Help/*.HxT 111 | DocProject/Help/*.HxC 112 | DocProject/Help/*.hhc 113 | DocProject/Help/*.hhk 114 | DocProject/Help/*.hhp 115 | DocProject/Help/Html2 116 | DocProject/Help/html 117 | 118 | # Click-Once directory 119 | publish/ 120 | 121 | # Publish Web Output 122 | *.[Pp]ublish.xml 123 | *.azurePubxml 124 | 125 | # NuGet Packages Directory 126 | packages/ 127 | ## TODO: If the tool you use requires repositories.config uncomment the next line 128 | #!packages/repositories.config 129 | 130 | # Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets 131 | # This line needs to be after the ignore of the build folder (and the packages folder if the line above has been uncommented) 132 | !packages/build/ 133 | 134 | # Windows Azure Build Output 135 | csx/ 136 | *.build.csdef 137 | 138 | # Windows Store app package directory 139 | AppPackages/ 140 | 141 | # Others 142 | sql/ 143 | *.Cache 144 | ClientBin/ 145 | [Ss]tyle[Cc]op.* 146 | ~$* 147 | *~ 148 | *.dbmdl 149 | *.dbproj.schemaview 150 | *.pfx 151 | *.publishsettings 152 | node_modules/ 153 | 154 | # RIA/Silverlight projects 155 | Generated_Code/ 156 | 157 | # Backup & report files from converting an old project file to a newer 158 | # Visual Studio version. Backup files are not needed, because we have git ;-) 159 | _UpgradeReport_Files/ 160 | Backup*/ 161 | UpgradeLog*.XML 162 | UpgradeLog*.htm 163 | 164 | # SQL Server files 165 | *.mdf 166 | *.ldf 167 | 168 | # Business Intelligence projects 169 | *.rdl.data 170 | *.bim.layout 171 | *.bim_*.settings 172 | 173 | # Microsoft Fakes 174 | FakesAssemblies/ 175 | 176 | # ========================= 177 | # Operating System Files 178 | # ========================= 179 | 180 | # OSX 181 | # ========================= 182 | 183 | .DS_Store 184 | .AppleDouble 185 | .LSOverride 186 | 187 | # Icon must ends with two \r. 188 | Icon 189 | 190 | # Thumbnails 191 | ._* 192 | 193 | # Files that might appear on external disk 194 | .Spotlight-V100 195 | .Trashes 196 | 197 | # Windows 198 | # ========================= 199 | 200 | # Windows image file caches 201 | Thumbs.db 202 | ehthumbs.db 203 | 204 | # Folder config file 205 | Desktop.ini 206 | 207 | # Recycle Bin used on file shares 208 | $RECYCLE.BIN/ 209 | 210 | # Windows Installer files 211 | *.cab 212 | *.msi 213 | *.msm 214 | *.msp 215 | -------------------------------------------------------------------------------- /src/AlertBarWpf.xaml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /src/AlertBarWpf.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {C6789390-E3DC-435E-B004-7E42B4218CF0} 8 | library 9 | Properties 10 | AlertBarWpf 11 | AlertBarWpf 12 | v4.5 13 | 512 14 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 15 | 4 16 | 17 | 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 4.0 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | MSBuild:Compile 52 | Designer 53 | 54 | 55 | AlertBarWpf.xaml 56 | Code 57 | 58 | 59 | 60 | 61 | Code 62 | 63 | 64 | True 65 | True 66 | Resources.resx 67 | 68 | 69 | True 70 | Settings.settings 71 | True 72 | 73 | 74 | ResXFileCodeGenerator 75 | Resources.Designer.cs 76 | 77 | 78 | SettingsSingleFileGenerator 79 | Settings.Designer.cs 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 108 | -------------------------------------------------------------------------------- /src/AlertBarWpf.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace AlertBarWpf 17 | { 18 | /// 19 | /// Interaction logic for UserControl1.xaml 20 | /// 21 | public partial class AlertBarWpf : UserControl 22 | { 23 | public AlertBarWpf() 24 | { 25 | InitializeComponent(); 26 | // grdWrapper.DataContext = this; 27 | } 28 | 29 | 30 | public static readonly RoutedEvent ShowEvent = EventManager.RegisterRoutedEvent("Show", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(AlertBarWpf)); 31 | 32 | public event RoutedEventHandler Show 33 | { 34 | add { AddHandler(ShowEvent, value); } 35 | remove { RemoveHandler(ShowEvent, value); } 36 | } 37 | 38 | private void RaiseShowEvent() 39 | { 40 | RoutedEventArgs newEventArgs = new RoutedEventArgs(AlertBarWpf.ShowEvent); 41 | RaiseEvent(newEventArgs); 42 | } 43 | 44 | private void TransformStage(string msg, int secs, string colorhex, string iconsrc) 45 | { 46 | 47 | 48 | SolidColorBrush bg = new SolidColorBrush(); 49 | bg = (SolidColorBrush)(new BrushConverter().ConvertFrom(colorhex)); 50 | 51 | Grid grdParent; 52 | switch (_Theme) 53 | { 54 | case ThemeType.Standard: 55 | spStandard.Visibility = System.Windows.Visibility.Visible; 56 | spOutline.Visibility = System.Windows.Visibility.Collapsed; 57 | 58 | grdParent = FindVisualChildren(spStandard).FirstOrDefault(); 59 | grdParent.Background = bg; 60 | break; 61 | case ThemeType.Outline: 62 | default: 63 | spStandard.Visibility = System.Windows.Visibility.Collapsed; 64 | spOutline.Visibility = System.Windows.Visibility.Visible; 65 | 66 | grdParent = FindVisualChildren(spOutline).FirstOrDefault(); 67 | bdr.BorderBrush = bg; 68 | break; 69 | } 70 | 71 | TextBlock lblMessage = FindVisualChildren(grdParent).FirstOrDefault(); 72 | List imgs = FindVisualChildren(grdParent).ToList(); 73 | Image imgStatusIcon = imgs[0]; 74 | Image imgCloseIcon = imgs[1]; 75 | 76 | 77 | if (_IconVisibility == false) 78 | { 79 | imgStatusIcon.Visibility = System.Windows.Visibility.Collapsed; 80 | grdParent.ColumnDefinitions.RemoveAt(0); 81 | lblMessage.SetValue(Grid.ColumnProperty, 0); 82 | imgCloseIcon.SetValue(Grid.ColumnProperty, 1); 83 | lblMessage.Margin = new Thickness(10, 4, 0, 4); 84 | lblMessage.Height = 16; 85 | } 86 | else 87 | { 88 | imgStatusIcon.Source = new BitmapImage(new Uri("/AlertBarWpf;component/Resources/" + iconsrc, UriKind.Relative)); 89 | } 90 | 91 | 92 | 93 | 94 | lblMessage.Text = msg; 95 | grdWrapper.Visibility = System.Windows.Visibility.Visible; 96 | key1.KeyTime = new TimeSpan(0, 0, (secs == 0 ? 0 : secs - 1)); 97 | key2.KeyTime = new TimeSpan(0, 0, secs); 98 | RaiseShowEvent(); 99 | } 100 | 101 | 102 | 103 | private static IEnumerable FindVisualChildren(DependencyObject depObj) where T : DependencyObject 104 | { 105 | if (depObj != null) 106 | { 107 | for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++) 108 | { 109 | DependencyObject child = VisualTreeHelper.GetChild(depObj, i); 110 | if (child != null && child is T) 111 | { 112 | yield return (T)child; 113 | } 114 | 115 | foreach (T childOfChild in FindVisualChildren(child)) 116 | { 117 | yield return childOfChild; 118 | } 119 | } 120 | } 121 | } 122 | 123 | 124 | /// 125 | /// Shows a Danger Alert 126 | /// 127 | /// The message for the alert 128 | /// Alert will auto-close in this amount of seconds 129 | public void SetDangerAlert(string message, int timeoutInSeconds = 0) 130 | { 131 | string color = "#D9534F"; 132 | string icon = "danger_16.png"; 133 | TransformStage(message, timeoutInSeconds, color, icon); 134 | } 135 | 136 | /// 137 | /// Shows a warning Alert 138 | /// 139 | /// The message for the alert 140 | /// Alert will auto-close in this amount of seconds 141 | public void SetWarningAlert(string message, int timeoutInSeconds = 0) 142 | { 143 | string color = "#F0AD4E"; 144 | string icon = "warning_16.png"; 145 | 146 | TransformStage(message, timeoutInSeconds, color, icon); 147 | } 148 | 149 | /// 150 | /// Shows a Success Alert 151 | /// 152 | /// The message for the alert 153 | /// Alert will auto-close in this amount of seconds 154 | public void SetSuccessAlert(string message, int timeoutInSeconds = 0) 155 | { 156 | string color = "#5CB85C"; 157 | string icon = "success_16.png"; 158 | TransformStage(message, timeoutInSeconds, color, icon); 159 | } 160 | 161 | 162 | /// 163 | /// Shows an Information Alert 164 | /// 165 | /// The message for the alert 166 | /// Alert will auto-close in this amount of seconds 167 | public void SetInformationAlert(string message, int timeoutInSeconds = 0) 168 | { 169 | string color = "#5BC0DE"; 170 | string icon = "information_16.png"; 171 | TransformStage(message, timeoutInSeconds, color, icon); 172 | } 173 | 174 | 175 | public enum ThemeType 176 | { 177 | Standard = 0, 178 | Outline = 1 179 | } 180 | 181 | private ThemeType _Theme = ThemeType.Standard; 182 | private bool _IconVisibility = true; 183 | 184 | /// 185 | /// Hide or show icons in the messages. 186 | /// 187 | public bool? IconVisibility 188 | { 189 | set 190 | { 191 | if (value == null) 192 | { 193 | return; 194 | } 195 | _IconVisibility = value ?? false; 196 | } 197 | get 198 | { 199 | return _IconVisibility; 200 | } 201 | } 202 | 203 | 204 | 205 | public ThemeType? Theme 206 | { 207 | set 208 | { 209 | if (value == null) 210 | { 211 | return; 212 | } 213 | if (Enum.IsDefined(typeof(ThemeType), value)) 214 | { 215 | _Theme = value ?? ThemeType.Standard; 216 | } 217 | } 218 | 219 | get 220 | { 221 | return _Theme; 222 | } 223 | } 224 | 225 | 226 | 227 | /// 228 | /// Remove a message if one is currently being shown. 229 | /// 230 | public void Clear() 231 | { 232 | grdWrapper.Visibility = System.Windows.Visibility.Collapsed; 233 | } 234 | 235 | private void Image_MouseUp(object sender, MouseButtonEventArgs e) 236 | { 237 | Clear(); 238 | 239 | } 240 | 241 | private void AnimationObject_Completed(object sender, EventArgs e) 242 | { 243 | if (grdWrapper.Opacity == 0) 244 | { 245 | //If you call msgbar.setErrorMessage("Whateva") in MainWindow() of your WPF the window is not rendered yet. So opacity is 0. If you have a timeout of 0 then it would call this immediately 246 | if (key1.KeyTime.TimeSpan.Seconds > 0) 247 | { 248 | Clear(); 249 | } 250 | } 251 | } 252 | 253 | } 254 | } 255 | --------------------------------------------------------------------------------