Use Font Glyph As Icon

2 posts, 0 answers
  1. David
    David avatar
    20 posts
    Member since:
    Nov 2015

    Posted 07 Oct Link to this post

    Hi there,

    Love the Desktop Alert component and love the font glyph's you guys have supplied as part of the Implicit Styling.

    How would I use a font glyph as my icon for a Desktop Alert?

    Thanks in advance,

    Dave

  2. Martin
    Admin
    Martin avatar
    61 posts

    Posted 11 Oct Link to this post

    Hello David,

    Yes, you can use them in the RadDesktopAlert. You can pass a DataTemplate in the IconTemplate property of the RadDesktopAlert. As an example:

    In your App.xaml:
    <ResourceDictionary>
      <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/Telerik.Windows.Themes.Office2016;component/Themes/System.Windows.xaml" />
        <ResourceDictionary Source="/Telerik.Windows.Themes.Office2016;component/Themes/Telerik.Windows.Controls.xaml" />
        <ResourceDictionary Source="/Telerik.Windows.Themes.Office2016;component/Themes/Telerik.Windows.Controls.Navigation.xaml" />
        <ResourceDictionary Source="/Telerik.Windows.Themes.Office2016;component/Themes/Telerik.Windows.Controls.Data.xaml" />
        <ResourceDictionary Source="/Telerik.Windows.Controls;component/Themes/FontResources.xaml"/>
      </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>

    In your MainWindow.xaml:
    <Window.Resources>
      <DataTemplate x:Key="GlyphTemplate">
        <TextBlock Text="{StaticResource GlyphCheck}" FontFamily="{StaticResource TelerikWebUI}" FontSize="32" Margin="0 0 10 0" />
      </DataTemplate>
    </Window.Resources>

    and in MainWindow.xaml.cs:
    private void RadButton_Click(object sender, RoutedEventArgs e)
    {
      var alert = new RadDesktopAlert();
      var dataTemplate = this.Resources["GlyphTemplate"] as DataTemplate;
      alert.IconTemplate = dataTemplate;
      alert.Header = "DONE NOTIFICATION";
      alert.Content = "This is a test fot Glyphs.";
      alert.ShowDuration = 3000;
     
      RadDesktopAlertManager manager = new RadDesktopAlertManager();
      manager.ShowAlert(alert);
    }

    I have used for the example the Office2016 theme, but the Glyph dictionary and font is accessible in all the themes for WPF with the need to merge the FontResources.xaml from Telerik.Windows.Controls.dll to use its contents as StaticResource references.

    Regards,
    Martin
    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top