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

Use Font Glyph As Icon

1 Answer 596 Views
DesktopAlert
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 07 Oct 2016, 04:59 PM

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

1 Answer, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 11 Oct 2016, 06:10 AM
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.
Tags
DesktopAlert
Asked by
David
Top achievements
Rank 1
Answers by
Martin
Telerik team
Share this question
or