A strange problem with WPF Window.Icon

I'm going to set Window.Icon property by using ResourceDictionary like below:

<Style TargetType="{x:Type Window}">
    <Setter Property="Icon" Value="/WpfApplication1;component/Resources/Icon.ico" />
</Style>

Above Style wasn't change Icon of Window. However when i set Icon of Window directly, It is done correctly!

<Window Icon="/WpfApplication1;component/Resources/Icon.ico">
    //Content
</Window>

Note: Build Action of Icon.ico was set to Resource and ResourceDictionary also loaded.

Answers


The problem is that your style is not applied at all. You'll have to define your style in app.xaml, assign a key to it and set your windows style explicitly. EDIT: Goblin suggested another valuable solution, excerpt from his comment: he could set the TargetType="{local:MainWindow}" where local is the namespace for WPFApplication1. The problem is that 'empty key'-application works only for the specified type - not descendants.


Need Your Help

How to display image in JSP with SPRING MVC

java image jsp url spring-mvc

I am new to spring mvc and I am trying to display an image on JSP.

transferring bytes from one ByteBuffer to another

java javadoc nio

What's the most efficient way to put as many bytes as possible from a ByteBuffer bbuf_src into another ByteBuffer bbuf_dest (as well as know how many bytes were transferred)? I'm trying

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.