This is a migrated thread and some comments may be shown as answers.

DesktopAlert not visible/not show

3 Answers 183 Views
DesktopAlert
This is a migrated thread and some comments may be shown as answers.
Jan
Top achievements
Rank 1
Jan asked on 01 Nov 2016, 08:35 PM

Hello,

I'd like to use a DesktopAlert in a WPF MVVM app.

I copy the code from the Telerik WPF app - DesktopAlert Examples - First Look app (email example).

Code:

public class AlertViewModel : BaseViewModel
{
private RadDesktopAlertManager desktopAlertManager;

public AlertViewModel()
{
this.desktopAlertManager = new RadDesktopAlertManager(AlertScreenPosition.BottomRight, 5d);
}

public Action ActivateMainWindowAction { get; set; }
private void OnAlertCommandExecuted(object param)
{            
if (this.ActivateMainWindowAction != null)
{
this.ActivateMainWindowAction.Invoke();
}            
}

public void TestAlert()
{
BitmapImage b = new BitmapImage();
b.BeginInit();
b.UriSource = new Uri("C:\\...\\error.png");
b.EndInit();

this.desktopAlertManager.ShowAlert(new DesktopAlertParameters
{
Header = "Header",
Content = "Content",
Icon = new Image { Source = b, Width = 48, Height = 48 },
IconColumnWidth = 48,
IconMargin = new Thickness(10, 0, 20, 0),
Command = new DelegateCommand(this.OnAlertCommandExecuted),
CommandParameter = "ABC"
});
}
}

public partial class Alert : UserControl
{
public Alert()
{
InitializeComponent();
AlertViewModel vm = ServiceLocator.Current.GetInstance<AlertViewModel>();
vm.ActivateMainWindowAction = new Action(this.ActivateMainWindow);
DataContext = vm;
}

private void ActivateMainWindow()
{
var mainWindow = Application.Current.MainWindow;

if (mainWindow != null)
{
if (mainWindow.WindowState == WindowState.Minimized)
{
mainWindow.WindowState = WindowState.Normal;
}

if (!mainWindow.IsActive)
{
mainWindow.Activate();
}
}
}
}

 

The DesktopAlertParameters command never execute and the alert never show.

Is there something i miss? If i try desktop alert on a new classic WPF app (no mvvm) works withuot problems.

 

Thanks.

 

3 Answers, 1 is accepted

Sort by
0
Nasko
Telerik team
answered on 03 Nov 2016, 08:44 AM
Hi Jan,

In order to show the DesktopAlert the "TestAlert" method should be called. Please, check the attached sample that demonstrates how to show the DesktopAlert as expected.

Hope this helps.

Regards,
Nasko
Telerik by Progress
Do you need help with upgrading your WPF project? Try the Telerik API Analyzer and share your thoughts!
0
Jan
Top achievements
Rank 1
answered on 19 Feb 2017, 07:29 PM

Hi,

how can we use desktop alert with prism and region manager?

 

 

0
Nasko
Telerik team
answered on 22 Feb 2017, 08:59 AM
Hello Jan,

Please, check the attached sample that demonstrates how to visualize RadDesktopAlert using Prism.

We hope this will help you.

Regards,
Nasko
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
DesktopAlert
Asked by
Jan
Top achievements
Rank 1
Answers by
Nasko
Telerik team
Jan
Top achievements
Rank 1
Share this question
or