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

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

2 Answers 109 Views
Window
This is a migrated thread and some comments may be shown as answers.
Sir
Top achievements
Rank 1
Sir asked on 23 Sep 2010, 02:19 AM

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

<telerik:RadWindow.IconTemplate>
    <DataTemplate>
        <Image Source="/Images/CompanyLogo.png" Stretch="None" />
    </DataTemplate>
</telerik:RadWindow.IconTemplate>

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 = ???
myDialog.ShowDialog();

Thanks,
Ray

2 Answers, 1 is accepted

Sort by
0
Accepted
Dani
Telerik team
answered on 24 Sep 2010, 07:02 AM
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,
Dani
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
0
Sir
Top achievements
Rank 1
answered on 25 Sep 2010, 02:32 AM
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 
};
Tags
Window
Asked by
Sir
Top achievements
Rank 1
Answers by
Dani
Telerik team
Sir
Top achievements
Rank 1
Share this question
or