Set an Icon in a Theme to apply to all RadWindows

2 posts, 0 answers
  1. Pedro
    Pedro avatar
    1 posts
    Member since:
    Nov 2016

    Posted 27 Nov 2016 Link to this post

    Hi Telerik team,

    What i'm trying to achieve is very simple, I just want to set an Icon image to RadWindow Template so it will be reflected in every RadWindow instances I create later:

     - I'm using Windows 8 theme and I have copied the needed XAML files.
     - The image is a .ico file from the folder "Resources\MyImage.ico"

    Although I have search in the documentation and in the forums I couldn't find a solution that find my needs, I do not want to use code behind to set the icon in every window.

    I'm looking forward your response.

    Best regards,
    Pedro Galusso

  2. Martin
    Admin
    Martin avatar
    126 posts

    Posted 28 Nov 2016 Link to this post

    Hello Pedro,

    You could create a global style for the RadWindow and define your image in its Icon setter. If you put/merge the style in your App.xaml and make it implicit (without a key), it will be applied to all the instances of the control:
    <Style BasedOn="{StaticResource RadWindowStyle}" TargetType="telerik:RadWindow">
      <Setter Property="Icon">
        <Setter.Value>
          <Image Source="<local path to your logo>" />
        </Setter.Value>
      </Setter>
    </Style>

    Note several things:

    To receive all the styling that we ship for the theme chosen, the style needs to be BasedOn on the default one (which needs to be merged in your application beforehand - in other words you need to define your style after the merged dictionaries for the theme).

    The Icon property provides value for a ContentPresenter, so you might need to define the image's Width and Height explicitly, and also - any limitations about images present in the WPF framework apply - e.g. the need for 96dpi for best rendering etc.

    Regards,
    Martin
    Telerik by Progress
    Telerik UI for WPF is ready for Visual Studio 2017 RC! Learn more.
Back to Top