How can I create an IconTemplate via C# code-behind?

3 posts, 1 answers
  1. Sir
    Sir avatar
    31 posts
    Member since:
    Mar 2008

    Posted 22 Sep 2010 Link to this post

    Using a xaml based RadWindow, I can have an icon by using the following markup:

            <Image Source="/Images/CompanyLogo.png" Stretch="None" />

    I have another page (code behind) where I want to create a RadWindow from scratch using C#, but I can't figure out how to duplicate the IconTemplate I'm using in the above xaml (the DependencyProperty of DataTemplate is tripping me up).  Can you help me with that by providing my missing C# IconTemplate ??? code?

    RadWindow myDialog = new RadWindow();
    myDialog.IconTemplate = ???

  2. Answer
    Dani avatar
    848 posts

    Posted 24 Sep 2010 Link to this post

    Hello Sir,

    Please, check our online help article on the topic. I believe what you need is the following line:

    radWindow.IconTemplate = this.Resources[ "WindowIconTemplate" ] as DataTemplate;

    All the best,
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Sir
    Sir avatar
    31 posts
    Member since:
    Mar 2008

    Posted 24 Sep 2010 Link to this post

    Thank you Dani.
    That link had the answer I needed.
    radWindow.Icon = new Image()
        Source = new BitmapImage(new Uri(headerIcon, UriKind.Relative)), Stretch=Stretch.None 
Back to Top