How to set the window icon programmatically?

4 posts, 0 answers
  1. Nestor Soriano Vilchez
    Nestor Soriano Vilchez avatar
    8 posts
    Member since:
    Dec 2009

    Posted 08 Jun 2010 Link to this post

    Is there any way to programmatically set the icon of a Window control? I am trying to set the Icon property of the window to an instance of BitmapImage that I have previously set up from a resource, but it does not work (no icon is shown whatsoever).
  2. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 09 Jun 2010 Link to this post

    Hi Nestor,

     You could refer to the following example: http://demos.telerik.com/silverlight/#Window/WindowIcon. You could use the same approach to set it in your code.

    Greetings,
    Miroslav Nedyalkov
    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. DevCraft banner
  4. Nestor Soriano Vilchez
    Nestor Soriano Vilchez avatar
    8 posts
    Member since:
    Dec 2009

    Posted 09 Jun 2010 Link to this post

    Thank you for your reply. I had looked at these examples already, and I understand how to set the window icon from a resource at design time. But what I want is to set the window icon after the window pbject has been instantiated (overwriting any other possible icon already in place). Something like this:

    var window = new RadWindow();
    //Set the window icon 
    window.Icon = ??? 
    //...now set another different icon 
    window.Icon = ??? 

  5. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 10 Jun 2010 Link to this post

    Hi Nestor,

     What you need to do is to create a new Image object, set its Width and Height and its Source and set the Icon property of the Window to be this Image. For more information about how to create and initialize Image in code-behind you could refer to the following forum thread: http://forums.silverlight.net/forums/p/11780/37722.aspx.

    Greetings,
    Miroslav Nedyalkov
    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.
Back to Top