Update: We are still using XP at work and I got my solution working, but now knowing that Vista and beyond have the isolated session I am going to implement a WCF IPC...
I have a windows service that needs to notify the user of an event of some type occurring. I decided that something similar to email notification messages would make sense. It also makes sense to do such a simple UI using WPF. This would allow me to learn some basics.
I run a thread:
Thread thread = new Thread(new ThreadStart(RunUserNotificationOnIndependantThread));
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
Then I set up the object and call the method that calls DoubleAnimation.BeginAnimation
private void RunUserNotificationOnIndependantThread()
{
UserNotificationWithImage test = new UserNotificationWithImage();
test.Title = _title;
test.Url = _url;
test.Message = _message;
test.LoadUserNotification();
}
public void LoadUserNotification()
{
Rect workAreaRectangle = System.Windows.SystemParameters.WorkArea;
Left = workAreaRectangle.Right - Width - BorderThickness.Right;
Top = workAreaRectangle.Bottom - Height - BorderThickness.Bottom;
_fadeInAnimation.Completed += new EventHandler(_fadeInAnimation_Completed);
// Start the fade in animation
BeginAnimation(UserNotificationBase.OpacityProperty, _fadeInAnimation);
}
The debugger reaches BeginAnimation(...) and no window appears. Is this even possible or what am I doing wrong in attempting this???
The UserNotification code is based on a blog by Nicke Andersson: WPF Desktop Alert blog
Thanks for any help!!