Telerik Forums
UI for WPF Forum
5 answers
330 views

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="&#xE11B;"/>
                </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);
        }
    }

 

 

Dilyan Traykov
Telerik team
 answered on 15 Apr 2021
2 answers
142 views

Hello, i tried to create radWindow as main window. I followed Your tutorial and it working well, except maximizing of window. When maximize button is pressed, then it only move to top left corner, but app itself stays in same size. Attached screenshot of maximized window. 

<telerik:RadWindow x:Name="MainWin1" x:Class="BORIS_OIL.MainWin"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:local="clr-namespace:BORIS_OIL"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:lang = "clr-namespace:BORIS_OIL.Properties"
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
        xmlns:navigation="clr-namespace:Telerik.Windows.Controls.Navigation;assembly=Telerik.Windows.Controls.Navigation"
        navigation:RadWindowInteropHelper.ShowInTaskbar="True"
        navigation:RadWindowInteropHelper.Icon="/Resources/aspera.ico"
        
        Header="{x:Static lang:Resources.App_Name}"  HorizontalAlignment="Center" VerticalAlignment="Center" WindowStartupLocation="CenterScreen" MinWidth="1366" MinHeight="768"  ResizeMode="CanResize" 
                >
    <telerik:RadWindow.Resources>
        
        <local:MainMenuViewModel x:Key="ViewModel" />
        <telerik:StringToGlyphConverter x:Key="StringToGlyphConverter" />

        <Style TargetType="telerik:RadNavigationViewItem" >
            <Setter Property="Content" Value="{Binding Title}" />
            <Setter Property="Icon" Value="{Binding IconGlyph}" />
            <Setter Property="IconTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <telerik:RadGlyph Glyph="{Binding Converter={StaticResource StringToGlyphConverter}}" />
                    </DataTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <DataTemplate x:Key="TransitionControlContentTemplate">
            <TextBlock Margin="10" Text="{Binding Title}" />
        </DataTemplate>

    </telerik:RadWindow.Resources>
    
    <Grid>
        <telerik:RadNavigationView DataContext="{StaticResource ViewModel}"  ItemsSource="{Binding Items}" PaneHeader="Menu" >
            <telerik:RadNavigationView.Content>
                <telerik:RadTransitionControl Content="{Binding SelectedItem, RelativeSource={RelativeSource AncestorType=telerik:RadNavigationView}}" ContentTemplate="{StaticResource TransitionControlContentTemplate}" Foreground="Black" Duration="0:0:0.4">
                    <telerik:RadTransitionControl.Transition>
                        <telerik:FadeTransition />
                    </telerik:RadTransitionControl.Transition>
                </telerik:RadTransitionControl>
            </telerik:RadNavigationView.Content>
        </telerik:RadNavigationView>
    </Grid>
    

Dinko | Tech Support Engineer
Telerik team
 answered on 15 Apr 2021
4 answers
153 views

Hi team,

I am using MVVM to create nodes, graphs and links. And i manage to create custom connectors with the help of this thread. But now i want to create custom connections, which means attach to specific custom connectors and add several connections points. Any tutorial showing how to do this?

 Thanks,

Jingfei

Dinko | Tech Support Engineer
Telerik team
 answered on 15 Apr 2021
1 answer
469 views

Hello,

I am using a RadGridView to show my Data. In this View I have a TextColumn with a Status. Now I want to bind a Enum with this Status to show my Value from the Enum in the RadGridView. My attempt was to define a property to return the StatusStype compared to the Status from my current Item.

But I do not exactly know how to do this. Or is there a better way?

Hope for some help :-)

My View

<telerik:RadGridView ItemsSource="{Binding Items}">
       <telerik:RadGridView.Columns>
         <telerik:TextColumn Header="Document" BindingValue="Document"/>
         <telerik:TextColumn Header="Status" BindingValue="StatusType"/>
       </telerik:RadGridView.Columns>
</telerik:RadGridView>

 

My Enum

public enum StatusTypes
    {
        [Description("Open")]
        Offen = 0,
        [Description("In Process")]
        InProcess = 1,
        [Description("Closed")]
        Closed = 2,
    }

 

My Model

public class MyModel
    {
        public string Document{ get; set; }
  
        public decimal Status { get; set; }
 
        public StatusTypes StatusType
        {
            get
            {
                return Status = StatusTypes
            }
        }
Vladimir Stoyanov
Telerik team
 answered on 14 Apr 2021
4 answers
95 views

I have a RadGrid that is bound to a ObservableCollection<Customer>. Users can click the RadGrid rows and create an ExpressionColumn using ExpressionEditor. I set ExpressionEditor.Item like:

RadExpressionEditor expressionEditor = new RadExpressionEditor();
expressionEditor.Item = this.myRadGrid.SelectedItem;

 

Users can create an expression like 'Customer.BankBalance + 100' and it gets added to the RadGrid:

 

private GridViewExpressionColumn expressionColumn = new GridViewExpressionColumn();
 
this.expressionColumn.Expression = expressionEditor.Expression;
this.expressionColumn.Header = "Test";
if (!this.myRadGrid.Columns.Contains(this.expressionColumn))
{
     this.myRadGrid.Columns.Add(this.expressionColumn);
}

How can I now use the newly created "Test" expression column in another ExpressionColumn by repeating the process the user has just done? So they would select a row but the "Test" column is now available to use in the ExpressionEditor and they could do an expression like "Test + 100".

YBOT
Top achievements
Rank 1
Veteran
 answered on 14 Apr 2021
1 answer
167 views

Hello,

I am using MVVM in RadDiagram.

I am facing a binding error when using style bindings to apply bindings on the RadDiagramShape properties. The binding works, but the error is a little bit anoying.

This is my XAML:

<Style TargetType="telerik:RadDiagramShape" BasedOn="{StaticResource RadDiagramShapeStyle}">
    <Setter Property="Background">
        <Setter.Value>
            <LinearGradientBrush>
                <LinearGradientBrush.GradientStops>
                    <GradientStop Offset="0" Color="{Binding BkgrdGradientColor1}" />
                    <GradientStop Offset="1" Color="{Binding BkgrdGradientColor2}" />
                </LinearGradientBrush.GradientStops>
            </LinearGradientBrush>
        </Setter.Value>
    </Setter>

 

This is the binding error:

Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=BkgrdGradientColor1; DataItem=null; target element is 'GradientStop' (HashCode=57039000); target property is 'Color' (type 'Color')

Can you help me with that?

regards,

Tobias

Peter
Top achievements
Rank 2
Iron
Iron
Veteran
 answered on 14 Apr 2021
1 answer
827 views

I have been racking my brains on this.  I am using Gridview with a CollectionView.  All fields are strings but they often contain numbers.  For example, "doctor1_21".  The problem is, the default sorting is not natural sorting. I followed your "Custom Sorting handling Sorting Event" example but can't seem to get it working with the CollectionView. I have six columns that are all strings and any of them should be able to sort naturally.  In a perfect word, I could tell the grid or collectionview to use a custom generic IComparerinst using this dllimport and just plug it in once and any column that is selected would sort ascending and descending using this natural sort.  But I simply cannot get it working.  Could you tell me the best way to implement this?  I have seen some where you have to designate the column name, but I would have to then do that for each column. I will do that if needed, but would be nice to have a more generic method.

 

[SuppressUnmanagedCodeSecurity]
    internal static class SafeNativeMethods
    {
        [DllImport("shlwapi.dll", CharSet = CharSet.Unicode)]
        public static extern int StrCmpLogicalW(string psz1, string psz2);
    }

Martin Ivanov
Telerik team
 answered on 14 Apr 2021
5 answers
304 views

Hello.

 

In the case of colorPickerOver, I want to remove the colorpicker borderthickness. I gave the thickness as 0, but it doesn't work.

And I want to fill the Rectangle in the ContentTemplate, but the red top, bottom, left and right gray margins remain.

 

In the case of color picker under, a split button was created to create a ColorPicker, but it is not synchronized with the button next to it.

And can you delete the arrow buttons?

<telerik:RadColorPicker Grid.Row="1"
                        x:Name="colorPickerOver"
                        VerticalAlignment="Center"
                        SelectedColor="{Binding OverColor, Mode=TwoWay}"
                        AutomaticColor="{Binding OverColor}"
                        IsRecentColorsActive="True"
                        NoColorText="Default"
                        Background="Transparent"
                        BorderBrush="Transparent"
                        BorderThickness="0"
                        >
    <telerik:RadColorPicker.ContentTemplate>
        <DataTemplate>
            <Rectangle Width="30" Height="30"
                       Fill="{Binding RelativeSource={RelativeSource Mode=FindAncestor,
                       AncestorType={x:Type telerik:RadColorPicker}},
                       Path=SelectedColor, Converter={StaticResource mediaToBrushConverter}}"/>
        </DataTemplate>
    </telerik:RadColorPicker.ContentTemplate>
 
    <telerik:RadColorPicker.AdditionalContent>
        <ContentControl HorizontalContentAlignment="Stretch" ContentTemplate="{StaticResource MoreColorsTemplate}" Content="{Binding}" />
    </telerik:RadColorPicker.AdditionalContent>
</telerik:RadColorPicker>
 
 
<telerik:RadColorPicker Grid.Row="2"
                        x:Name="colorPickerUnder"
                        VerticalAlignment="Center"
                        SelectedColor="{Binding UnderColor, Mode=TwoWay}"
                        AutomaticColor="{Binding UnderColor}"
                        IsRecentColorsActive="True"
                        NoColorText="Default"
                        Background="Transparent"
                        BorderBrush="Transparent"
                        BorderThickness="0"
                        >
    <telerik:RadColorPicker.ContentTemplate>
        <DataTemplate>
            <telerik:RadDropDownButton Padding="0" Height="30" Width="30" BorderThickness="0" DropDownIndicatorVisibility="Collapsed">
                <telerik:RadDropDownButton.Content>
                    <Rectangle Width="{Binding ActualWidth, RelativeSource={RelativeSource AncestorType=telerik:RadColorPicker}}"
                               Height="{Binding ActualHeight, RelativeSource={RelativeSource AncestorType=telerik:RadColorPicker}}">
                        <Rectangle.Fill>
                            <SolidColorBrush Color="{Binding }"/>
                        </Rectangle.Fill>
                    </Rectangle>
                </telerik:RadDropDownButton.Content>
                <telerik:RadDropDownButton.DropDownContent>
                    <telerik:RadColorSelector />
                </telerik:RadDropDownButton.DropDownContent>
            </telerik:RadDropDownButton>
        </DataTemplate>
    </telerik:RadColorPicker.ContentTemplate>

 

 

 

 

Thanks.

Dilyan Traykov
Telerik team
 answered on 13 Apr 2021
1 answer
135 views

hello,

how can i place legend horizontally in RadCartesianChart which is placed vertically by default.

Thans!

ALi
Top achievements
Rank 1
 answered on 13 Apr 2021
2 answers
139 views
I use a RadNavigationView for my whole application.  I whipped up a context menu for it that I set on it.  But I want my context menu to only appear when the user right-clicks on the "Pane" part of the RadNavigationView -- the part on the left, not for the content part on the right.  How may I do this? 

I tried looking at the visual structure of the control template to see if there is some sort of distinct control representing just the pane whose "ContextMenu" property I could set but I could not spot anything.

I really do not want to redefine the whole ControlTemplate.

Any ideas?
Martin Ivanov
Telerik team
 answered on 12 Apr 2021
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?