We are working on project and using Telerik with MVVM approach using Prism framework.
We want to notify user about some tasks or messages for which we have used RadNotifyIcon.
We are able to notify user but we want to give a link in the notification on click of which user will be redirected to some internal Menu page(a XAML page within the application).
For Menu control we have used Rad Navigation View(Hamburger Menu) and it is working fine when navigated from one menu to another.
We are facing a challenge in achieving the same using PRSIM MVVM approach. We are not getting the click event(Command) of the hyperlink present in NotifyIcon to ViewModel to navigate to the view.
Kindly help us to achieve this. Below is our code let us know where are we going wrong or is there any other way to navigate to existing view using Radnotifyicon link click?
We have tried RadHyperlink control as well as RadRadioButton. Both are not working
Below is the designer code:
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:av="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:prism="http://prismlibrary.com/"
mc:Ignorable="av" x:Class="Voyager.Views.Notifications"
prism:ViewModelLocator.AutoWireViewModel="True"
av:DesignWidth="718.431" av:DesignHeight="416.528">
<UserControl.Resources>
<DataTemplate x:Key="CalloutContentTemplate">
<StackPanel Width="300">
<telerik:RadButton Cursor="Hand" IsBackgroundVisible="False"
Padding="0" VerticalAlignment="Top" HorizontalAlignment="Right"
Command="{x:Static telerik:WindowCommands.Close}">
<telerik:RadGlyph Glyph=""/>
</telerik:RadButton>
<Image Source="/Images/Splash3.PNG" />
<TextBlock TextWrapping="Wrap" MaxWidth="200" x:Name="Notification" FontWeight="Bold" Margin="0 0 0 10"/>
<!--<telerik:RadHyperlinkButton x:Name="RadHyperlinkButton1" Content="Click here to open Telerik WPF Documentation" Command="{Binding MyCommand}" CommandParameter="InternetUsage"-->
<telerik:RadRadioButton Command="{Binding MyCommand}"
CommandParameter="InternetUsage"
Tag="ACTIVITIES" Style="{StaticResource RadRadioButtonLargeStyle}"/>
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="NotifyIconPopupContentTemplate">
<telerik:RadCallout x:Name="CalloutButton" ArrowAnchorPoint="0.8,1.1"
ArrowBasePoint1="1,0.5"
ArrowBasePoint2="0.6,0.5"
ArrowType="Triangle"
Padding="10 15"
TextAlignment="Left"
Margin="30"
ContentTemplate="{StaticResource CalloutContentTemplate}"/>
</DataTemplate>
</UserControl.Resources>
<Grid HorizontalAlignment="Center" VerticalAlignment="Center" FocusManager.FocusedElement="{Binding ElementName=ShowNotifyIconButton}">
<Border BorderThickness="1" BorderBrush="#33000000" Width="500">
<StackPanel VerticalAlignment="Stretch">
<TextBlock HorizontalAlignment="Center" Foreground="#FF333333" Margin="0 30 0 35" FontSize="24" Text="Welcome to RadNotifyIcon demos"/>
<TextBlock HorizontalAlignment="Center" Margin="0 0 0 10" FontSize="16" Text="Click on the button below to show the NotifyIcon in the tray area."/>
<TextBlock HorizontalAlignment="Center" Foreground="#FF0099BC" FontSize="12" Text="Note, that the icon may be hidden in the overflow area of the notification tray."/>
<telerik:RadButton x:Name="ShowNotifyIconButton"
Loaded="OnShowNotifyIconButtonLoaded"
HorizontalAlignment="Center" MinWidth="170" Margin="0 40 0 30" Content="Show NotifyIcon" Click="OnShowNotifyIconButtonClick" />
<telerik:RadNotifyIcon x:Name="NotifyIcon"
ShowTrayIcon="True"
TrayIconSource="/Images/voyager_icon_green.ico"
PopupContentTemplate="{StaticResource NotifyIconPopupContentTemplate}" PopupShowDuration="10000" TrayIconMouseUp="NotifyIcon_TrayIconMouseUp"/>
</StackPanel>
</Border>
</Grid>
</UserControl>
Below is the ViewModel code:
public class NotificationsViewModel : BindableBase
{
public IRegionManager _regionManager = null;
public NotificationsViewModel(IRegionManager regionManager)
{
_regionManager = regionManager;
MyCommand = new DelegateCommand<string>(OnCommandExecuted);
}
private void OnCommandExecuted(string url)
{
Navigate(url);
}
public ICommand MyCommand { get; set; }
public void Navigate(string navigatePath)
{
_regionManager.RequestNavigate("ContentRegion", navigatePath);
}
}