Hi,
I'm new to Telerik and I use a trial version of telerik devcraft.
I'd like to use a Desktop Alert in VB.Net and WPF but I don't know how, and I don't find any documentation for it. Can you explain me how to use it ?
Thanks,
Clément.
15 Answers, 1 is accepted
In order to show a DesktopAlert, you would need firstly to create an instance of RadDesktopAlertManager:
Dim
manager =
New
RadDesktopAlertManager()
And then using its ShowAlert method to show the alert:
Dim
alert =
New
RadDesktopAlert()
With
{
Key .Header =
"MAIL NOTIFICATION"
,
Key .Content =
"Hello, Here are two things that we noticed today on our daily meeting."
,
Key .Command =
New
DelegateCommand(OnCommandExecuted),
Key .ShowDuration = 5000
}
manager.ShowAlert(alert)
For details regarding the control, you can check the DesktopAlert online documentation on the following link:
http://docs.telerik.com/devtools/wpf/controls/raddesktopalert/getting-started
Hope this helps.
Regards,
Kalin
Telerik
Thanks Kalin, I have to others questions : is this possible to manage the opacity of the alert ?
alert.opacity = 75 for exemple isn't working
And is this possible to change the animation to make the alert appear by a slide up or slide down ?
Thanks,
Clément
The Opacity property works with values from 0 to 1, so try setting it in that range the see result. However with the current implementation this would be only initially applied - when you mouse enter and then mouse leave the control the opacity would be set to 0.9. This done from a StoryBoard named DesktopAlertOnMouseLeave inside of the DesktopAlert Styles - you can modify it there as per your needs.
As for the other question you can check the following article from our help documentation that explains how to change the Show/Hide animation either with single or multiple ones:
http://docs.telerik.com/devtools/wpf/controls/raddesktopalert/how-to/apply-multiple-animations-for-showing-and-hiding-raddesktopalert
You can also check this demo from our XAML SDK Repository:
https://github.com/telerik/xaml-sdk/tree/master/DesktopAlert/ShowingAndHidingUsingAnimationGroup
As well as you can check the Configurator DesktopAlert example in our WPF Demos where more different animations are demonstrated:
http://demos.telerik.com/wpf/
Hope this helps.
Regards,
Kalin
Telerik
Is there anything else to import than Telerik.Windows.Controls ?
Because if I do :
Dim
alert =
New
RadDesktopAlert
alert.Header =
"Header"
alert.Content =
"Content"
alert.ShowDuration = 6000
Dim
manager =
New
RadDesktopAlertManager(AlertScreenPosition.TopRight,
New
System.Windows.Point(-5, 5))
manager.ShowAnimation =
New
FadeAnimation()
With
{
Key.Direction = AnimationDirection.Out,
Key.MinOpacity = 0.5,
Key.MaxOpacity = 0.9,
Key.SpeedRatio = 0.5
}
manager.ShowAlert(alert)
the part "manager.ShowAnimation(...)" isn't working (FadeAnimation isn't declared and I have 4 errors like this : "Name of field or property being initialized in an object initializer must start with '.'")
EDIT : Solved by removing "key"
There is my last question : How to set alert Icon ? I tried :
alert.Icon = New BitmapImage() With {.UriSource = New Uri("pack://application:,,,/questions1.png")}
But it's not working (there is no icon when the alert is shown) and code you provide in support is not working too
When setting the Icon you would need to also set the IconColumnWidth property with the desired size reserved for the icon. You can also check the IconMargin property for more precise aligning the icon of RadDesktopAlert.
Hope this helps.
Regards,
Kalin
Telerik
Hi,
I'm unable to see the desktop notification on using below code in a simple WPF application.
private void Button_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show("You clicked me");
var alert = new RadDesktopAlert();
alert.Header = "MAIL NOTIFICATION";
alert.Content = "Hello, Here are two things that we noticed today on our daily meeting.";
alert.ShowDuration = 30000;
alert.Opacity = 75;
RadDesktopAlertManager manager = new RadDesktopAlertManager(AlertScreenPosition.BottomRight);
manager.ShowAlert(alert);
}
This code executes on click of a button in a simple WPF App.
I use Win 10 machine, with .net framework 4.7.2 and VS 2017.
Can someone please help?
Regards,
Naga
Thank you for the code snippet.
I tested it on the enviroment you described and it worked as expected. However, one possible scenario might be if you're using NoXaml binaries and the resources of the theme aren't merged on Application level i.e App.xaml.
Can you please confirm if this is the case? For your convenience, I've prepared a small sample project that demonstrates how to use RadDesktopAlert using NoXaml, which you can find attached. Please, review and if necessary, update it with your logic and send it back to me, so I can further investigate.
Regards,
Dimitar Dinev
Progress Telerik
Thanks Dimitar !!
In case of NoXaml dlls
working : if resources are in app.xaml file and when i use MainWindow.xaml as startup page
not working : if resources are in user control and user control is being used in MainWindow.xaml
I would like to see the alerts from user control in which resources are included
The RadDesktopAlert is hosted in a separate WPF Window, so it can't access the merged styles in another Window (the UserControl in the MainWindow). However there are two options I can suggest you in order to be able to style the RadDesktopAlert using NoXaml. The first is, as mentioned, to merge the resources in App.xaml and the other is to merge the resources into the control itself as shown below:
private
void
Button_Click(
object
sender, RoutedEventArgs e)
{
var alert =
new
RadDesktopAlert
{
Header =
"MAIL NOTIFICATION"
,
Content =
"Hello, Here are two things that we noticed today on our daily meeting."
,
ShowDuration = 5000
};
alert.Resources.MergedDictionaries.Add(
new
ResourceDictionary()
{
Source =
new
Uri(
"/Telerik.Windows.Themes.Office_Black;component/Themes/System.Windows.xaml"
, UriKind.RelativeOrAbsolute)
});
alert.Resources.MergedDictionaries.Add(
new
ResourceDictionary()
{
Source =
new
Uri(
"/Telerik.Windows.Themes.Office_Black;component/Themes/Telerik.Windows.Controls.xaml"
, UriKind.RelativeOrAbsolute)
});
alert.Resources.MergedDictionaries.Add(
new
ResourceDictionary()
{
Source =
new
Uri(
"/Telerik.Windows.Themes.Office_Black;component/Themes/Telerik.Windows.Controls.Navigation.xaml"
, UriKind.RelativeOrAbsolute)
});
manager.ShowAlert(alert);
}
Please, let me know if this helps.
Regards,
Dimitar Dinev
Progress Telerik
Hi Dimitar,
Thanks for your reply. It worked for us. Thanks for your help.
Regards,
Naga
Hi Dimitar
I tried following the suggestions, but something is still not quite right.
I have the following code:
RadDesktopAlertManager testManager = new RadDesktopAlertManager(AlertScreenPosition.BottomRight);
RadDesktopAlert testAlert = new RadDesktopAlert();
testAlert.Resources.MergedDictionaries.Add(new ResourceDictionary()
{
Source = new Uri("/Telerik.Windows.Themes.VisualStudio2013;component/Themes/System.Windows.xaml", UriKind.RelativeOrAbsolute)
});
testAlert.Resources.MergedDictionaries.Add(new ResourceDictionary()
{
Source = new Uri("/Telerik.Windows.Themes.VisualStudio2013;component/Themes/Telerik.Windows.Controls.xaml", UriKind.RelativeOrAbsolute)
});
testAlert.Resources.MergedDictionaries.Add(new ResourceDictionary()
{
Source = new Uri("/Telerik.Windows.Themes.VisualStudio2013;component/Themes/Telerik.Windows.Controls.Navigation.xaml", UriKind.RelativeOrAbsolute)
});
testManager.ShowAnimation = new FadeAnimation { SpeedRatio = 20 };
testManager.HideAnimation = new FadeAnimation { SpeedRatio = 20 };
testAlert.Style = null;
testAlert.ShowDuration = 3000;
testAlert.BorderThickness = new Thickness(0);
testAlert.Background = Brushes.Black;
testAlert.Foreground = Brushes.White;
testAlert.Content = "Testing123";
testManager.ShowAlert(testAlert);
If i tab out i can see there is a "hidden" window but it does not seem to have any content or styles.
Your help would be appreciated.
Kind Regards
Dawid
Hello Dawid,
I've replied to your Support Ticket with the reason for the problem, I wanted to follow up here in case it is helpful to someone in the community.
The reason for the missing styling is because testAlert.Style is set to null. When that line is commented out (or deleted), you will see the following alert:
Regards,
Lance | Team Lead - US DevTools Support
Progress Telerik
Thank you this was indeed the issue.
Thank you for the quick response!